Change in openvpn[master]: Remove various useless assignments
A message that is not in the archive (sent off-list or not yet received): gerrit.1775421558000.Id0caa497c4ff1ad8743cb23f332f003b2d3393ed@gerrit.openvpn.net
Attention is currently required from: plaisthos.
Hello plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/1617?usp=email
to look at the new patch set (#9).
Change subject: Remove various useless assignments
......................................................................
Remove various useless assignments
The values assigned by these are never actually used for something.
Identified by cppcheck.
---
M src/openvpn/console_builtin.c
M src/openvpn/crypto.c
M src/openvpn/error.h
M src/openvpn/forward.c
M src/openvpn/manage.c
M src/openvpn/options.c
M src/openvpn/pkcs11.c
M src/openvpn/pkcs11_openssl.c
M src/openvpn/push_util.c
M src/openvpn/socket.c
M src/openvpn/ssl_openssl.c
M src/openvpn/win32.c
M src/openvpnmsica/openvpnmsica.c
M src/tapctl/tap.c
M tests/unit_tests/openvpn/test_ssl.c
15 files changed, 37 insertions(+), 54 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/17/1617/9
src/openvpn/console_builtin.c +5 -5
@@ -192,7 +192,6 @@static bool get_console_input (const char *prompt,const bool echo,char *input,const int capacity) { -bool ret = false;ASSERT (prompt);ASSERT (input);ASSERT (capacity >0 );
@@ -200,8 +199,11 @@#if defined(_WIN32)return get_console_input_win32 (prompt, echo, input, capacity); -#elif defined(HAVE_TERMIOS_H ) +#elif !defined(HAVE_TERMIOS_H ) +msg (M_FATAL ,"Sorry, but I can't get console input on this OS (%s)" , prompt); +#else bool restore_tty = false; +bool ret = false;struct termios tty_tmp, tty_save;/* did we --daemon'ize before asking for passwords?
@@ -258,10 +260,8 @@ }close_tty (fp); -#else /* if defined(_WIN32) */ -msg (M_FATAL ,"Sorry, but I can't get console input on this OS (%s)" , prompt); -#endif /* if defined(_WIN32) */ return ret; +#endif /* if defined(_WIN32) */ }/**
src/openvpn/crypto.c +2 -4
@@ -1204,8 +1204,6 @@struct buffer work =alloc_buf_gc (BUF_SIZE (frame), &gc);struct buffer encrypt_workspace =alloc_buf_gc (BUF_SIZE (frame), &gc);struct buffer decrypt_workspace =alloc_buf_gc (BUF_SIZE (frame), &gc); -struct buffer buf =clear_buf (); -void *buf_p;/* init work */ ASSERT (buf_init (&work, frame->buf.headroom));
@@ -1242,8 +1240,8 @@ASSERT (rand_bytes (BPTR (&src),BLEN (&src)));/* copy source to input buf */ - buf = work; - buf_p =buf_write_alloc (&buf,BLENZ (&src)); +struct buffer buf = work; +void *buf_p =buf_write_alloc (&buf,BLENZ (&src));ASSERT (buf_p);memcpy (buf_p,BPTR (&src),BLENZ (&src));
src/openvpn/error.h +1 -1
@@ -408,8 +408,8 @@ openvpn_errno_maybe_crt(bool *crt_error) {int err =0 ; - *crt_error = false;#ifdef _WIN32 + *crt_error = false; err =GetLastError ();if (err ==ERROR_SUCCESS ) {
src/openvpn/forward.c +1 -2
@@ -1748,7 +1748,6 @@ process_outgoing_link(struct context *c, struct link_socket *sock) { struct gc_arena gc = gc_new(); -int error_code =0 ;if (c->c2.to_link.len >0 && c->c2.to_link.len <= c->c2.frame.buf.payload_size) {
@@ -1823,7 +1822,7 @@ }/* Check return status */ - error_code =openvpn_errno (); +int error_code =openvpn_errno ();check_status (size,"write" , sock,NULL );if (size >0 )
src/openvpn/manage.c +2 -3
@@ -916,10 +916,9 @@static void man_remote_entry_count (struct management *man) { -unsigned count =0 ;if (man->persist.callback.remote_entry_count) { - count = (*man->persist.callback.remote_entry_count)(man->persist.callback.arg); +unsigned int count = (*man->persist.callback.remote_entry_count)(man->persist.callback.arg);msg (M_CLIENT ,"%u" , count);msg (M_CLIENT ,"END" ); }
@@ -3745,7 +3744,6 @@struct gc_arena gc =gc_new ();int ret =0 ;volatile int signal_received =0 ; -struct buffer alert_msg =clear_buf ();const bool standalone_disabled_save = man->persist.standalone_disabled;struct man_connection *mc = &man->connection;
@@ -3757,6 +3755,7 @@ *state =EKS_SOLICIT ; +struct buffer alert_msg;if (b64_data) { alert_msg =alloc_buf_gc (strlen (b64_data) +strlen (prompt) +3 , &gc);
src/openvpn/options.c +0 -1
@@ -7110,7 +7110,6 @@if (streq (p[1 ],"FORWARD_COMPATIBLE" ) && p[2 ] &&streq (p[2 ],"1" )) { options->forward_compatible = true; - msglevel_fc =msglevel_forward_compatible (options, msglevel); }setenv_str (es, p[1 ], p[2 ] ? p[2 ] :"" ); }
src/openvpn/pkcs11.c +8 -8
@@ -79,6 +79,9 @@static msglvl_t _pkcs11_msg_pkcs112openvpn (const unsigned flags) { +#ifdef ENABLE_PKCS11_FORCE_DEBUG +return M_INFO ; +#else msglvl_t openvpn_flags; switch (flags)
@@ -108,16 +111,16 @@ break; } -#if defined(ENABLE_PKCS11_FORCE_DEBUG ) - openvpn_flags =M_INFO ; -#endif -return openvpn_flags; +#endif }static unsigned _pkcs11_msg_openvpn2pkcs11 (const msglvl_t flags) { +#ifdef ENABLE_PKCS11_FORCE_DEBUG +return PKCS11H_LOG_DEBUG2 ; +#else unsigned pkcs11_flags;if ((flags &D_PKCS11_DEBUG ) !=0 )
@@ -145,11 +148,8 @@ pkcs11_flags =PKCS11H_LOG_ERROR ; } -#if defined(ENABLE_PKCS11_FORCE_DEBUG ) - pkcs11_flags =PKCS11H_LOG_DEBUG2 ; -#endif -return pkcs11_flags; +#endif } static void
src/openvpn/pkcs11_openssl.c +0 -2
@@ -384,7 +384,6 @@if (certificate !=NULL ) {pkcs11h_certificate_freeCertificate (certificate); - certificate =NULL ; }/*
@@ -400,7 +399,6 @@if (openssl_session !=NULL ) {pkcs11h_openssl_freeSession (openssl_session); - openssl_session =NULL ; }return ret;#endif /* ifdef HAVE_XKEY_PROVIDER */
src/openvpn/push_util.c +3 -5
@@ -99,7 +99,6 @@ }char *str =gc_strdup (s, gc); -size_t i =0 ;while (*str) {
@@ -112,11 +111,11 @@/* if no commas were found go to fail, do not send any message */ return false; } +/* copy from current position to (ci - 1) */ str[ci] ='\0' ; -/* copy from i to (ci -1) */ struct buffer tmp =forge_msg (str,",push-continuation 2" , gc);buffer_list_push (msgs,BSTR (&tmp)); - i = ci +1 ; + str += ci +1 ; }else {
@@ -130,9 +129,8 @@struct buffer tmp =forge_msg (str,NULL , gc);buffer_list_push (msgs,BSTR (&tmp)); } - i =strlen (str); +break ; } - str = &str[i]; }return true; }
src/openvpn/socket.c +1 -1
@@ -789,7 +789,7 @@*/ socklen_t remote_len_af =af_addr_size (act->dest.addr.sa.sa_family);socklen_t remote_len =sizeof (act->dest.addr); -socket_descriptor_t new_sd =SOCKET_UNDEFINED ; +socket_descriptor_t new_sd;CLEAR (*act);
src/openvpn/ssl_openssl.c +4 -6
@@ -2354,13 +2354,13 @@ }int typeid =EVP_PKEY_id (pkey); + +#ifndef OPENSSL_NO_EC #if OPENSSL_VERSION_NUMBER <0x30000000L bool is_ec = typeid ==EVP_PKEY_EC ;#else bool is_ec =EVP_PKEY_is_a (pkey,"EC" );#endif - -#ifndef OPENSSL_NO_EC char groupname[64 ];if (is_ec) {
@@ -2668,15 +2668,13 @@ "builtin EC curves. It does not list additional curves nor X448 or X25519\n");#ifndef OPENSSL_NO_EC EC_builtin_curve *curves =NULL ; -size_t crv_len =0 ; -size_t n =0 ; - crv_len =EC_get_builtin_curves (NULL ,0 ); +size_t crv_len =EC_get_builtin_curves (NULL ,0 );ALLOC_ARRAY (curves, EC_builtin_curve, crv_len);if (EC_get_builtin_curves (curves, crv_len)) {printf ("\nAvailable Elliptic curves/groups:\n" ); -for (n =0 ; n < crv_len; n++) +for (size_t n =0 ; n < crv_len; n++) {const char *sname; sname =OBJ_nid2sn (curves[n].nid);
src/openvpn/win32.c +4 -3
@@ -1293,9 +1293,6 @@is_wow64_process2_t is_wow64_process2 = (is_wow64_process2_t )GetProcAddress (GetModuleHandle ("Kernel32.dll" ),"IsWow64Process2" ); -USHORT process_machine =0 ; -USHORT native_machine =0 ; -#ifdef _ARM64_ *process_arch =ARCH_ARM64 ;#elif defined(_WIN64)
@@ -1303,6 +1300,8 @@if (is_wow64_process2) {/* this could be amd64 on arm64 */ +USHORT process_machine =0 ; +USHORT native_machine =0 ;BOOL is_wow64 =is_wow64_process2 (GetCurrentProcess (), &process_machine, &native_machine);if (is_wow64 && native_machine ==IMAGE_FILE_MACHINE_ARM64 ) {
@@ -1315,6 +1314,8 @@if (is_wow64_process2) {/* check if we're running on arm64 or amd64 machine */ +USHORT process_machine =0 ; +USHORT native_machine =0 ;BOOL is_wow64 =is_wow64_process2 (GetCurrentProcess (), &process_machine, &native_machine);if (is_wow64) {
src/openvpnmsica/openvpnmsica.c +0 -1
@@ -711,7 +711,6 @@ uiResult =MsiViewFetch (hViewST, &hRecord);if (uiResult ==ERROR_NO_MORE_ITEMS ) { - uiResult =ERROR_SUCCESS ;break ; }else if (uiResult !=ERROR_SUCCESS )
src/tapctl/tap.c +2 -4
@@ -473,7 +473,7 @@return ERROR_OUTOFMEMORY ; } - dwCountExpResult =ExpandEnvironmentStrings (szValue, szValueExp, dwCountExp); +ExpandEnvironmentStrings (szValue, szValueExp, dwCountExp);free (szValue); *pszValue = szValueExp;return ERROR_SUCCESS ;
@@ -601,8 +601,6 @@ _In_ DWORD dwProperty, _Out_opt_ LPDWORD pdwPropertyRegDataType, _Out_ LPVOID *ppData) { - DWORD dwResult = ERROR_BAD_ARGUMENTS; - if (ppData == NULL) { return ERROR_BAD_ARGUMENTS;
@@ -628,7 +626,7 @@ }else { - dwResult =GetLastError (); +DWORD dwResult =GetLastError ();if (dwResult ==ERROR_INSUFFICIENT_BUFFER ) {/* Allocate on heap and retry. */
tests/unit_tests/openvpn/test_ssl.c +4 -8
@@ -303,8 +303,6 @@struct buffer work =alloc_buf_gc (BUF_SIZE (&frame), &gc);struct buffer encrypt_workspace =alloc_buf_gc (BUF_SIZE (&frame), &gc);struct buffer decrypt_workspace =alloc_buf_gc (BUF_SIZE (&frame), &gc); -struct buffer buf =clear_buf (); -void *buf_p;/* init work */ ASSERT (buf_init (&work, frame.buf.headroom));
@@ -325,8 +323,8 @@ASSERT (rand_bytes (BPTR (&src),BLEN (&src)));/* copy source to input buf */ - buf = work; - buf_p =buf_write_alloc (&buf,BLENZ (&src)); +struct buffer buf = work; +void *buf_p =buf_write_alloc (&buf,BLENZ (&src));ASSERT (buf_p);memcpy (buf_p,BPTR (&src),BLENZ (&src));
@@ -356,7 +354,6 @@struct buffer encrypt_workspace =alloc_buf_gc (BUF_SIZE (&frame), &gc);struct buffer decrypt_workspace =alloc_buf_gc (BUF_SIZE (&frame), &gc);struct buffer work =alloc_buf_gc (BUF_SIZE (&frame), &gc); -struct buffer buf =clear_buf ();struct buffer src =alloc_buf_gc (frame.buf.payload_size, &gc);void *buf_p;
@@ -371,7 +368,7 @@ASSERT (rand_bytes (BPTR (&src),BLEN (&src)));/* copy source to input buf */ - buf = work; +struct buffer buf = work; buf_p =buf_write_alloc (&buf,BLENZ (&src));ASSERT (buf_p);memcpy (buf_p,BPTR (&src),BLENZ (&src));
@@ -652,7 +649,6 @@struct buffer work =alloc_buf_gc (BUF_SIZE (&frame), &gc);struct buffer encrypt_workspace =alloc_buf_gc (BUF_SIZE (&frame), &gc);struct buffer decrypt_workspace =alloc_buf_gc (BUF_SIZE (&frame), &gc); -struct buffer buf =clear_buf ();void *buf_p;/* init work */
@@ -669,7 +665,7 @@ASSERT (buf_write (&src, plaintext,strlen (plaintext)));/* copy source to input buf */ - buf = work; +struct buffer buf = work; buf_p =buf_write_alloc (&buf,BLENZ (&src));ASSERT (buf_p);memcpy (buf_p,BPTR (&src),BLENZ (&src));
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1617?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Id0caa497c4ff1ad8743cb23f332f003b2d3393ed
Gerrit-Change-Number: 1617
Gerrit-PatchSet: 9
Gerrit-Owner: flichtenheld <[email protected]>
Gerrit-Reviewer: plaisthos <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Attention is currently required from: flichtenheld.
plaisthos has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1617?usp=email )
Change subject: Remove various useless assignments
......................................................................
Patch Set 11:
(1 comment)
Patchset:
PS11:
This commit also removes the initalisation of the buffer by = clear_buf(); While that might do something. I think that change should be explained in the commit message or the initisation should be kept or replace by a simple = { 0 }; since that is what clear_buf does anyway.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1617?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Id0caa497c4ff1ad8743cb23f332f003b2d3393ed
Gerrit-Change-Number: 1617
Gerrit-PatchSet: 11
Gerrit-Owner: flichtenheld <[email protected]>
Gerrit-Reviewer: plaisthos <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]>
Gerrit-Comment-Date: Sat, 08 Aug 2026 13:13:30 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Attention is currently required from: plaisthos.
flichtenheld has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1617?usp=email )
Change subject: Remove various useless assignments
......................................................................
Patch Set 11:
(1 comment)
Patchset:
PS11:
Quoted 1 line
This commit also removes the initalisation of the buffer by =
clear_buf(); While that might do somet […]
In don't understand your point. As the commit message says we only remove assignments of values that are never used for anything.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1617?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Id0caa497c4ff1ad8743cb23f332f003b2d3393ed
Gerrit-Change-Number: 1617
Gerrit-PatchSet: 11
Gerrit-Owner: flichtenheld <[email protected]>
Gerrit-Reviewer: plaisthos <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]>
Gerrit-Comment-Date: Mon, 10 Aug 2026 12:02:09 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: plaisthos <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Attention is currently required from: flichtenheld, plaisthos.
stipa has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1617?usp=email )
Change subject: Remove various useless assignments
......................................................................
Patch Set 11:
(1 comment)
File src/openvpn/console_builtin.c:
http://gerrit.openvpn.net/c/openvpn/+/1617/comment/ed7d4c69_3b98ea0a?usp=email :
PS11, Line 203: msg(M_FATAL, "Sorry, but I can't get console input on this OS (%s)", prompt);
this loses return. M_FATAL means exit, but won't we get a compiler warning on the platforms which are not WIN32 and don't have termios? The fix would be moving "return red" in the end of function above #endif.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1617?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Id0caa497c4ff1ad8743cb23f332f003b2d3393ed
Gerrit-Change-Number: 1617
Gerrit-PatchSet: 11
Gerrit-Owner: flichtenheld <[email protected]>
Gerrit-Reviewer: plaisthos <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: stipa <[email protected]>
Gerrit-Attention: plaisthos <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]>
Gerrit-Comment-Date: Thu, 13 Aug 2026 12:58:49 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Attention is currently required from: plaisthos, stipa.
flichtenheld has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1617?usp=email )
Change subject: Remove various useless assignments
......................................................................
Patch Set 12:
(1 comment)
File src/openvpn/console_builtin.c:
http://gerrit.openvpn.net/c/openvpn/+/1617/comment/a42ad3c9_4f641da3?usp=email :
PS11, Line 203: msg(M_FATAL, "Sorry, but I can't get console input on this OS (%s)", prompt);
Quoted 1 line
this loses return. […]
In general we added EXIT_FATAL macro to msg() exactly so that tools would not complain. We do not usually add return statements after M_FATAL. But of course in most functions there is some return still afterwards.
Not sure how we would test this specific instance. I don't know if we even have a platform where this code branch is used...
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1617?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Id0caa497c4ff1ad8743cb23f332f003b2d3393ed
Gerrit-Change-Number: 1617
Gerrit-PatchSet: 12
Gerrit-Owner: flichtenheld <[email protected]>
Gerrit-Reviewer: plaisthos <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: stipa <[email protected]>
Gerrit-Attention: plaisthos <[email protected]>
Gerrit-Attention: stipa <[email protected]>
Gerrit-Comment-Date: Fri, 14 Aug 2026 10:40:57 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: stipa <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Attention is currently required from: plaisthos, stipa.
Hello plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/1617?usp=email
to look at the new patch set (#15).
Change subject: Remove various useless assignments
......................................................................
Remove various useless assignments
The values assigned by these are never actually used for something.
Identified by cppcheck.
---
M dev-tools/cppcheck-suppression
M src/openvpn/console_builtin.c
M src/openvpn/crypto.c
M src/openvpn/error.h
M src/openvpn/forward.c
M src/openvpn/manage.c
M src/openvpn/options.c
M src/openvpn/pkcs11.c
M src/openvpn/pkcs11_openssl.c
M src/openvpn/push_util.c
M src/openvpn/socket.c
M src/openvpn/ssl_openssl.c
M src/openvpn/win32.c
M src/openvpnmsica/openvpnmsica.c
M src/tapctl/tap.c
M tests/unit_tests/openvpn/test_ssl.c
16 files changed, 38 insertions(+), 58 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/17/1617/15
dev-tools/cppcheck-suppression +1 -4
@@ -5,9 +5,6 @@ constParameterPointer invalidPrintfArgType_sint invalidPrintfArgType_uint -redundantAssignment -redundantInitialization -unreadVariable unusedFunction usleepCalled variableScope
@@ -77,7 +74,7 @@ # IGN: strlen(NULL) is not nice code, but seems to work nullPointerRedundantCheck:src/openvpn/init.c:301 # FP: cppcheck doesn't understand ZeroMemory -redundantAssignment:src/openvpnserv/interactive.c:203 +redundantAssignment:src/openvpnserv/interactive.c:204 # FP: cppcheck doesn't know the NLA macros redundantInitialization:src/openvpn/dco_linux.c # IGN: We reuse the same variable name due to macro usage
src/openvpn/console_builtin.c +5 -5
@@ -192,7 +192,6 @@static bool get_console_input (const char *prompt,const bool echo,char *input,const int capacity) { -bool ret = false;ASSERT (prompt);ASSERT (input);ASSERT (capacity >0 );
@@ -200,8 +199,11 @@#if defined(_WIN32)return get_console_input_win32 (prompt, echo, input, capacity); -#elif defined(HAVE_TERMIOS_H ) +#elif !defined(HAVE_TERMIOS_H ) +msg (M_FATAL ,"Sorry, but I can't get console input on this OS (%s)" , prompt); +#else bool restore_tty = false; +bool ret = false;struct termios tty_tmp, tty_save;/* did we --daemon'ize before asking for passwords?
@@ -258,10 +260,8 @@ }close_tty (fp); -#else /* if defined(_WIN32) */ -msg (M_FATAL ,"Sorry, but I can't get console input on this OS (%s)" , prompt); -#endif /* if defined(_WIN32) */ return ret; +#endif /* if defined(_WIN32) */ }/**
src/openvpn/crypto.c +2 -4
@@ -1204,8 +1204,6 @@struct buffer work =alloc_buf_gc (BUF_SIZE (frame), &gc);struct buffer encrypt_workspace =alloc_buf_gc (BUF_SIZE (frame), &gc);struct buffer decrypt_workspace =alloc_buf_gc (BUF_SIZE (frame), &gc); -struct buffer buf =clear_buf (); -void *buf_p;/* init work */ ASSERT (buf_init (&work, frame->buf.headroom));
@@ -1242,8 +1240,8 @@prng_bytes (BPTR (&src),BLEN (&src));/* copy source to input buf */ - buf = work; - buf_p =buf_write_alloc (&buf,BLENZ (&src)); +struct buffer buf = work; +void *buf_p =buf_write_alloc (&buf,BLENZ (&src));ASSERT (buf_p);memcpy (buf_p,BPTR (&src),BLENZ (&src));
src/openvpn/error.h +1 -1
@@ -408,8 +408,8 @@ openvpn_errno_maybe_crt(bool *crt_error) {int err =0 ; - *crt_error = false;#ifdef _WIN32 + *crt_error = false; err =GetLastError ();if (err ==ERROR_SUCCESS ) {
src/openvpn/forward.c +1 -2
@@ -1746,7 +1746,6 @@ process_outgoing_link(struct context *c, struct link_socket *sock) { struct gc_arena gc = gc_new(); -int error_code =0 ;if (c->c2.to_link.len >0 && c->c2.to_link.len <= c->c2.frame.buf.payload_size) {
@@ -1821,7 +1820,7 @@ }/* Check return status */ - error_code =openvpn_errno (); +int error_code =openvpn_errno ();check_status (size,"write" , sock,NULL );if (size >0 )
src/openvpn/manage.c +2 -3
@@ -916,10 +916,9 @@static void man_remote_entry_count (struct management *man) { -unsigned count =0 ;if (man->persist.callback.remote_entry_count) { - count = (*man->persist.callback.remote_entry_count)(man->persist.callback.arg); +unsigned int count = (*man->persist.callback.remote_entry_count)(man->persist.callback.arg);msg (M_CLIENT ,"%u" , count);msg (M_CLIENT ,"END" ); }
@@ -3743,7 +3742,6 @@struct gc_arena gc =gc_new ();int ret =0 ;volatile int signal_received =0 ; -struct buffer alert_msg =clear_buf ();const bool standalone_disabled_save = man->persist.standalone_disabled;struct man_connection *mc = &man->connection;
@@ -3755,6 +3753,7 @@ *state =EKS_SOLICIT ; +struct buffer alert_msg;if (b64_data) { alert_msg =alloc_buf_gc (strlen (b64_data) +strlen (prompt) +3 , &gc);
src/openvpn/options.c +0 -1
@@ -5691,7 +5691,6 @@if (streq (p[1 ],"FORWARD_COMPATIBLE" ) && p[2 ] &&streq (p[2 ],"1" )) { options->forward_compatible = true; - msglevel_fc =msglevel_forward_compatible (options, msglevel); }setenv_str (es, p[1 ], p[2 ] ? p[2 ] :"" ); }
src/openvpn/pkcs11.c +8 -8
@@ -80,6 +80,9 @@static msglvl_t _pkcs11_msg_pkcs112openvpn (const unsigned flags) { +#ifdef ENABLE_PKCS11_FORCE_DEBUG +return M_INFO ; +#else msglvl_t openvpn_flags; switch (flags)
@@ -109,16 +112,16 @@ break; } -#if defined(ENABLE_PKCS11_FORCE_DEBUG ) - openvpn_flags =M_INFO ; -#endif -return openvpn_flags; +#endif }static unsigned _pkcs11_msg_openvpn2pkcs11 (const msglvl_t flags) { +#ifdef ENABLE_PKCS11_FORCE_DEBUG +return PKCS11H_LOG_DEBUG2 ; +#else unsigned pkcs11_flags;if ((flags &D_PKCS11_DEBUG ) !=0 )
@@ -146,11 +149,8 @@ pkcs11_flags =PKCS11H_LOG_ERROR ; } -#if defined(ENABLE_PKCS11_FORCE_DEBUG ) - pkcs11_flags =PKCS11H_LOG_DEBUG2 ; -#endif -return pkcs11_flags; +#endif } static void
src/openvpn/pkcs11_openssl.c +0 -2
@@ -384,7 +384,6 @@if (certificate !=NULL ) {pkcs11h_certificate_freeCertificate (certificate); - certificate =NULL ; }/*
@@ -400,7 +399,6 @@if (openssl_session !=NULL ) {pkcs11h_openssl_freeSession (openssl_session); - openssl_session =NULL ; }return ret;#endif /* ifdef HAVE_XKEY_PROVIDER */
src/openvpn/push_util.c +3 -5
@@ -99,7 +99,6 @@ }char *str =gc_strdup (s, gc); -size_t i =0 ;while (*str) {
@@ -112,11 +111,11 @@/* if no commas were found go to fail, do not send any message */ return false; } +/* copy from current position to (ci - 1) */ str[ci] ='\0' ; -/* copy from i to (ci -1) */ struct buffer tmp =forge_msg (str,",push-continuation 2" , gc);buffer_list_push (msgs,BSTR (&tmp)); - i = ci +1 ; + str += ci +1 ; }else {
@@ -130,9 +129,8 @@struct buffer tmp =forge_msg (str,NULL , gc);buffer_list_push (msgs,BSTR (&tmp)); } - i =strlen (str); +break ; } - str = &str[i]; }return true; }
src/openvpn/socket.c +1 -1
@@ -761,7 +761,7 @@*/ socklen_t remote_len_af =af_addr_size (act->dest.addr.sa.sa_family);socklen_t remote_len =sizeof (act->dest.addr); -socket_descriptor_t new_sd =SOCKET_UNDEFINED ; +socket_descriptor_t new_sd;CLEAR (*act);
src/openvpn/ssl_openssl.c +4 -6
@@ -2283,13 +2283,13 @@ }int typeid =EVP_PKEY_id (pkey); + +#ifndef OPENSSL_NO_EC #if OPENSSL_VERSION_NUMBER <0x30000000L bool is_ec = typeid ==EVP_PKEY_EC ;#else bool is_ec =EVP_PKEY_is_a (pkey,"EC" );#endif - -#ifndef OPENSSL_NO_EC char groupname[64 ];if (is_ec) {
@@ -2593,15 +2593,13 @@ "builtin EC curves. It does not list additional curves nor X448 or X25519\n");#ifndef OPENSSL_NO_EC EC_builtin_curve *curves =NULL ; -size_t crv_len =0 ; -size_t n =0 ; - crv_len =EC_get_builtin_curves (NULL ,0 ); +size_t crv_len =EC_get_builtin_curves (NULL ,0 );ALLOC_ARRAY (curves, EC_builtin_curve, crv_len);if (EC_get_builtin_curves (curves, crv_len)) {printf ("\nAvailable Elliptic curves/groups:\n" ); -for (n =0 ; n < crv_len; n++) +for (size_t n =0 ; n < crv_len; n++) {const char *sname; sname =OBJ_nid2sn (curves[n].nid);
src/openvpn/win32.c +4 -3
@@ -1293,9 +1293,6 @@is_wow64_process2_t is_wow64_process2 = (is_wow64_process2_t )GetProcAddress (GetModuleHandle ("Kernel32.dll" ),"IsWow64Process2" ); -USHORT process_machine =0 ; -USHORT native_machine =0 ; -#ifdef _ARM64_ *process_arch =ARCH_ARM64 ;#elif defined(_WIN64)
@@ -1303,6 +1300,8 @@if (is_wow64_process2) {/* this could be amd64 on arm64 */ +USHORT process_machine =0 ; +USHORT native_machine =0 ;BOOL is_wow64 =is_wow64_process2 (GetCurrentProcess (), &process_machine, &native_machine);if (is_wow64 && native_machine ==IMAGE_FILE_MACHINE_ARM64 ) {
@@ -1315,6 +1314,8 @@if (is_wow64_process2) {/* check if we're running on arm64 or amd64 machine */ +USHORT process_machine =0 ; +USHORT native_machine =0 ;BOOL is_wow64 =is_wow64_process2 (GetCurrentProcess (), &process_machine, &native_machine);if (is_wow64) {
src/openvpnmsica/openvpnmsica.c +0 -1
@@ -711,7 +711,6 @@ uiResult =MsiViewFetch (hViewST, &hRecord);if (uiResult ==ERROR_NO_MORE_ITEMS ) { - uiResult =ERROR_SUCCESS ;break ; }else if (uiResult !=ERROR_SUCCESS )
src/tapctl/tap.c +2 -4
@@ -473,7 +473,7 @@return ERROR_OUTOFMEMORY ; } - dwCountExpResult =ExpandEnvironmentStrings (szValue, szValueExp, dwCountExp); +ExpandEnvironmentStrings (szValue, szValueExp, dwCountExp);free (szValue); *pszValue = szValueExp;return ERROR_SUCCESS ;
@@ -601,8 +601,6 @@ _In_ DWORD dwProperty, _Out_opt_ LPDWORD pdwPropertyRegDataType, _Out_ LPVOID *ppData) { - DWORD dwResult = ERROR_BAD_ARGUMENTS; - if (ppData == NULL) { return ERROR_BAD_ARGUMENTS;
@@ -628,7 +626,7 @@ }else { - dwResult =GetLastError (); +DWORD dwResult =GetLastError ();if (dwResult ==ERROR_INSUFFICIENT_BUFFER ) {/* Allocate on heap and retry. */
tests/unit_tests/openvpn/test_ssl.c +4 -8
@@ -292,8 +292,6 @@struct buffer work =alloc_buf_gc (BUF_SIZE (&frame), &gc);struct buffer encrypt_workspace =alloc_buf_gc (BUF_SIZE (&frame), &gc);struct buffer decrypt_workspace =alloc_buf_gc (BUF_SIZE (&frame), &gc); -struct buffer buf =clear_buf (); -void *buf_p;/* init work */ ASSERT (buf_init (&work, frame.buf.headroom));
@@ -314,8 +312,8 @@prng_bytes (BPTR (&src),BLEN (&src));/* copy source to input buf */ - buf = work; - buf_p =buf_write_alloc (&buf,BLENZ (&src)); +struct buffer buf = work; +void *buf_p =buf_write_alloc (&buf,BLENZ (&src));ASSERT (buf_p);memcpy (buf_p,BPTR (&src),BLENZ (&src));
@@ -345,7 +343,6 @@struct buffer encrypt_workspace =alloc_buf_gc (BUF_SIZE (&frame), &gc);struct buffer decrypt_workspace =alloc_buf_gc (BUF_SIZE (&frame), &gc);struct buffer work =alloc_buf_gc (BUF_SIZE (&frame), &gc); -struct buffer buf =clear_buf ();struct buffer src =alloc_buf_gc (frame.buf.payload_size, &gc);void *buf_p;
@@ -360,7 +357,7 @@prng_bytes (BPTR (&src),BLEN (&src));/* copy source to input buf */ - buf = work; +struct buffer buf = work; buf_p =buf_write_alloc (&buf,BLENZ (&src));ASSERT (buf_p);memcpy (buf_p,BPTR (&src),BLENZ (&src));
@@ -641,7 +638,6 @@struct buffer work =alloc_buf_gc (BUF_SIZE (&frame), &gc);struct buffer encrypt_workspace =alloc_buf_gc (BUF_SIZE (&frame), &gc);struct buffer decrypt_workspace =alloc_buf_gc (BUF_SIZE (&frame), &gc); -struct buffer buf =clear_buf ();void *buf_p;/* init work */
@@ -658,7 +654,7 @@ASSERT (buf_write (&src, plaintext,strlen (plaintext)));/* copy source to input buf */ - buf = work; +struct buffer buf = work; buf_p =buf_write_alloc (&buf,BLENZ (&src));ASSERT (buf_p);memcpy (buf_p,BPTR (&src),BLENZ (&src));
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1617?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Id0caa497c4ff1ad8743cb23f332f003b2d3393ed
Gerrit-Change-Number: 1617
Gerrit-PatchSet: 15
Gerrit-Owner: flichtenheld <[email protected]>
Gerrit-Reviewer: plaisthos <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: stipa <[email protected]>
Gerrit-Attention: plaisthos <[email protected]>
Gerrit-Attention: stipa <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Attention is currently required from: plaisthos, stipa.
Hello plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/1617?usp=email
to look at the new patch set (#20).
Change subject: Remove various useless assignments
......................................................................
Remove various useless assignments
The values assigned by these are never actually used for something.
Identified by cppcheck.
---
M dev-tools/cppcheck-suppression
M src/openvpn/console_builtin.c
M src/openvpn/crypto.c
M src/openvpn/error.h
M src/openvpn/forward.c
M src/openvpn/manage.c
M src/openvpn/options.c
M src/openvpn/pkcs11.c
M src/openvpn/pkcs11_openssl.c
M src/openvpn/push_util.c
M src/openvpn/socket.c
M src/openvpn/ssl_openssl.c
M src/openvpn/win32.c
M src/openvpnmsica/openvpnmsica.c
M src/tapctl/tap.c
M tests/unit_tests/openvpn/test_ssl.c
16 files changed, 43 insertions(+), 63 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/17/1617/20
dev-tools/cppcheck-suppression +1 -4
@@ -5,9 +5,6 @@ constParameterPointer invalidPrintfArgType_sint invalidPrintfArgType_uint -redundantAssignment -redundantInitialization -unreadVariable unusedFunction usleepCalled variableScope
@@ -74,7 +71,7 @@ # IGN: strlen(NULL) is not nice code, but seems to work nullPointerRedundantCheck:src/openvpn/init.c:301 # FP: cppcheck doesn't understand ZeroMemory -redundantAssignment:src/openvpnserv/interactive.c:203 +redundantAssignment:src/openvpnserv/interactive.c:204 # IGN: We reuse the same variable name due to macro usage shadowVariable:src/openvpn/options.c:1948 shadowVariable:src/openvpn/options.c:1966
src/openvpn/console_builtin.c +5 -5
@@ -192,7 +192,6 @@static bool get_console_input (const char *prompt,const bool echo,char *input,const int capacity) { -bool ret = false;ASSERT (prompt);ASSERT (input);ASSERT (capacity >0 );
@@ -200,8 +199,11 @@#if defined(_WIN32)return get_console_input_win32 (prompt, echo, input, capacity); -#elif defined(HAVE_TERMIOS_H ) +#elif !defined(HAVE_TERMIOS_H ) +msg (M_FATAL ,"Sorry, but I can't get console input on this OS (%s)" , prompt); +#else bool restore_tty = false; +bool ret = false;struct termios tty_tmp, tty_save;/* did we --daemon'ize before asking for passwords?
@@ -258,10 +260,8 @@ }close_tty (fp); -#else /* if defined(_WIN32) */ -msg (M_FATAL ,"Sorry, but I can't get console input on this OS (%s)" , prompt); -#endif /* if defined(_WIN32) */ return ret; +#endif /* if defined(_WIN32) */ }/**
src/openvpn/crypto.c +2 -4
@@ -1204,8 +1204,6 @@struct buffer work =alloc_buf_gc (BUF_SIZE (frame), &gc);struct buffer encrypt_workspace =alloc_buf_gc (BUF_SIZE (frame), &gc);struct buffer decrypt_workspace =alloc_buf_gc (BUF_SIZE (frame), &gc); -struct buffer buf =clear_buf (); -void *buf_p;/* init work */ ASSERT (buf_init (&work, frame->buf.headroom));
@@ -1242,8 +1240,8 @@prng_bytes (BPTR (&src),BLEN (&src));/* copy source to input buf */ - buf = work; - buf_p =buf_write_alloc (&buf,BLENZ (&src)); +struct buffer buf = work; +void *buf_p =buf_write_alloc (&buf,BLENZ (&src));ASSERT (buf_p);memcpy (buf_p,BPTR (&src),BLENZ (&src));
src/openvpn/error.h +1 -1
@@ -408,8 +408,8 @@ openvpn_errno_maybe_crt(bool *crt_error) {int err =0 ; - *crt_error = false;#ifdef _WIN32 + *crt_error = false; err =GetLastError ();if (err ==ERROR_SUCCESS ) {
src/openvpn/forward.c +1 -2
@@ -1746,7 +1746,6 @@ process_outgoing_link(struct context *c, struct link_socket *sock) { struct gc_arena gc = gc_new(); -int error_code =0 ;if (c->c2.to_link.len >0 && c->c2.to_link.len <= c->c2.frame.buf.payload_size) {
@@ -1821,7 +1820,7 @@ }/* Check return status */ - error_code =openvpn_errno (); +int error_code =openvpn_errno ();check_status (size,"write" , sock,NULL );if (size >0 )
src/openvpn/manage.c +2 -3
@@ -916,10 +916,9 @@static void man_remote_entry_count (struct management *man) { -unsigned count =0 ;if (man->persist.callback.remote_entry_count) { - count = (*man->persist.callback.remote_entry_count)(man->persist.callback.arg); +unsigned int count = (*man->persist.callback.remote_entry_count)(man->persist.callback.arg);msg (M_CLIENT ,"%u" , count);msg (M_CLIENT ,"END" ); }
@@ -3740,7 +3739,6 @@struct gc_arena gc =gc_new ();int ret =0 ;volatile int signal_received =0 ; -struct buffer alert_msg =clear_buf ();const bool standalone_disabled_save = man->persist.standalone_disabled;struct man_connection *mc = &man->connection;
@@ -3752,6 +3750,7 @@ *state =EKS_SOLICIT ; +struct buffer alert_msg;if (b64_data) { alert_msg =alloc_buf_gc (strlen (b64_data) +strlen (prompt) +3 , &gc);
src/openvpn/options.c +1 -3
@@ -4157,8 +4157,7 @@bool key_is_external (const struct options *options) { -bool ret = false; - ret = ret || (options->management_flags &MF_EXTERNAL_KEY ); +bool ret = options->management_flags &MF_EXTERNAL_KEY ;#ifdef ENABLE_PKCS11 ret = ret || (options->pkcs11_providers[0 ] !=NULL );#endif
@@ -5697,7 +5696,6 @@if (streq (p[1 ],"FORWARD_COMPATIBLE" ) && p[2 ] &&streq (p[2 ],"1" )) { options->forward_compatible = true; - msglevel_fc =msglevel_forward_compatible (options, msglevel); }setenv_str (es, p[1 ], p[2 ] ? p[2 ] :"" ); }
src/openvpn/pkcs11.c +8 -8
@@ -80,6 +80,9 @@static msglvl_t _pkcs11_msg_pkcs112openvpn (const unsigned flags) { +#ifdef ENABLE_PKCS11_FORCE_DEBUG +return M_INFO ; +#else msglvl_t openvpn_flags; switch (flags)
@@ -109,16 +112,16 @@ break; } -#if defined(ENABLE_PKCS11_FORCE_DEBUG ) - openvpn_flags =M_INFO ; -#endif -return openvpn_flags; +#endif }static unsigned _pkcs11_msg_openvpn2pkcs11 (const msglvl_t flags) { +#ifdef ENABLE_PKCS11_FORCE_DEBUG +return PKCS11H_LOG_DEBUG2 ; +#else unsigned pkcs11_flags;if ((flags &D_PKCS11_DEBUG ) !=0 )
@@ -146,11 +149,8 @@ pkcs11_flags =PKCS11H_LOG_ERROR ; } -#if defined(ENABLE_PKCS11_FORCE_DEBUG ) - pkcs11_flags =PKCS11H_LOG_DEBUG2 ; -#endif -return pkcs11_flags; +#endif } static void
src/openvpn/pkcs11_openssl.c +0 -2
@@ -384,7 +384,6 @@if (certificate !=NULL ) {pkcs11h_certificate_freeCertificate (certificate); - certificate =NULL ; }/*
@@ -400,7 +399,6 @@if (openssl_session !=NULL ) {pkcs11h_openssl_freeSession (openssl_session); - openssl_session =NULL ; }return ret;#endif /* ifdef HAVE_XKEY_PROVIDER */
src/openvpn/push_util.c +3 -5
@@ -99,7 +99,6 @@ }char *str =gc_strdup (s, gc); -size_t i =0 ;while (*str) {
@@ -112,11 +111,11 @@/* if no commas were found go to fail, do not send any message */ return false; } +/* copy from current position to (ci - 1) */ str[ci] ='\0' ; -/* copy from i to (ci -1) */ struct buffer tmp =forge_msg (str,",push-continuation 2" , gc);buffer_list_push (msgs,BSTR (&tmp)); - i = ci +1 ; + str += ci +1 ; }else {
@@ -130,9 +129,8 @@struct buffer tmp =forge_msg (str,NULL , gc);buffer_list_push (msgs,BSTR (&tmp)); } - i =strlen (str); +break ; } - str = &str[i]; }return true; }
src/openvpn/socket.c +1 -1
@@ -753,7 +753,7 @@*/ socklen_t remote_len_af =af_addr_size (act->dest.addr.sa.sa_family);socklen_t remote_len =sizeof (act->dest.addr); -socket_descriptor_t new_sd =SOCKET_UNDEFINED ; +socket_descriptor_t new_sd;CLEAR (*act);
src/openvpn/ssl_openssl.c +4 -6
@@ -2283,13 +2283,13 @@ }int typeid =EVP_PKEY_id (pkey); + +#ifndef OPENSSL_NO_EC #if OPENSSL_VERSION_NUMBER <0x30000000L bool is_ec = typeid ==EVP_PKEY_EC ;#else bool is_ec =EVP_PKEY_is_a (pkey,"EC" );#endif - -#ifndef OPENSSL_NO_EC char groupname[64 ];if (is_ec) {
@@ -2593,15 +2593,13 @@ "builtin EC curves. It does not list additional curves nor X448 or X25519\n");#ifndef OPENSSL_NO_EC EC_builtin_curve *curves =NULL ; -size_t crv_len =0 ; -size_t n =0 ; - crv_len =EC_get_builtin_curves (NULL ,0 ); +size_t crv_len =EC_get_builtin_curves (NULL ,0 );ALLOC_ARRAY (curves, EC_builtin_curve, crv_len);if (EC_get_builtin_curves (curves, crv_len)) {printf ("\nAvailable Elliptic curves/groups:\n" ); -for (n =0 ; n < crv_len; n++) +for (size_t n =0 ; n < crv_len; n++) {const char *sname; sname =OBJ_nid2sn (curves[n].nid);
src/openvpn/win32.c +4 -3
@@ -1340,9 +1340,6 @@is_wow64_process2_t is_wow64_process2 = (is_wow64_process2_t )GetProcAddress (GetModuleHandle ("Kernel32.dll" ),"IsWow64Process2" ); -USHORT process_machine =0 ; -USHORT native_machine =0 ; -#ifdef _ARM64_ *process_arch =ARCH_ARM64 ;#elif defined(_WIN64)
@@ -1350,6 +1347,8 @@if (is_wow64_process2) {/* this could be amd64 on arm64 */ +USHORT process_machine =0 ; +USHORT native_machine =0 ;BOOL is_wow64 =is_wow64_process2 (GetCurrentProcess (), &process_machine, &native_machine);if (is_wow64 && native_machine ==IMAGE_FILE_MACHINE_ARM64 ) {
@@ -1362,6 +1361,8 @@if (is_wow64_process2) {/* check if we're running on arm64 or amd64 machine */ +USHORT process_machine =0 ; +USHORT native_machine =0 ;BOOL is_wow64 =is_wow64_process2 (GetCurrentProcess (), &process_machine, &native_machine);if (is_wow64) {
src/openvpnmsica/openvpnmsica.c +0 -1
@@ -711,7 +711,6 @@ uiResult =MsiViewFetch (hViewST, &hRecord);if (uiResult ==ERROR_NO_MORE_ITEMS ) { - uiResult =ERROR_SUCCESS ;break ; }else if (uiResult !=ERROR_SUCCESS )
src/tapctl/tap.c +2 -4
@@ -473,7 +473,7 @@return ERROR_OUTOFMEMORY ; } - dwCountExpResult =ExpandEnvironmentStrings (szValue, szValueExp, dwCountExp); +ExpandEnvironmentStrings (szValue, szValueExp, dwCountExp);free (szValue); *pszValue = szValueExp;return ERROR_SUCCESS ;
@@ -601,8 +601,6 @@ _In_ DWORD dwProperty, _Out_opt_ LPDWORD pdwPropertyRegDataType, _Out_ LPVOID *ppData) { - DWORD dwResult = ERROR_BAD_ARGUMENTS; - if (ppData == NULL) { return ERROR_BAD_ARGUMENTS;
@@ -628,7 +626,7 @@ }else { - dwResult =GetLastError (); +DWORD dwResult =GetLastError ();if (dwResult ==ERROR_INSUFFICIENT_BUFFER ) {/* Allocate on heap and retry. */
tests/unit_tests/openvpn/test_ssl.c +8 -11
@@ -217,7 +217,7 @@#if !defined(HAVE_OPENSSL_STORE )skip (); -#else /* HAVE_OPENSSL_STORE */ +#else /* HAVE_OPENSSL_STORE */ struct tls_root_ctx ctx = {0 };const char *certfile = global_state.certfile;
@@ -228,9 +228,10 @@struct buffer keyuri =alloc_buf_gc (6 +strlen (keyfile) +1 , gc);/* 6 bytes for "file:/" */ /* Windows temp file path starts with drive letter -- add a leading slash for URI */ -const char *lead ="" ;#ifdef _WIN32 - lead ="/" ; +const char *lead ="/" ; +#else +const char *lead ="" ;#endif /* _WIN32 */ assert_true (buf_printf (&certuri,"file:%s%s" , lead, certfile));assert_true (buf_printf (&keyuri,"file:%s%s" , lead, keyfile));
@@ -292,8 +293,6 @@struct buffer work =alloc_buf_gc (BUF_SIZE (&frame), &gc);struct buffer encrypt_workspace =alloc_buf_gc (BUF_SIZE (&frame), &gc);struct buffer decrypt_workspace =alloc_buf_gc (BUF_SIZE (&frame), &gc); -struct buffer buf =clear_buf (); -void *buf_p;/* init work */ ASSERT (buf_init (&work, frame.buf.headroom));
@@ -314,8 +313,8 @@prng_bytes (BPTR (&src),BLEN (&src));/* copy source to input buf */ - buf = work; - buf_p =buf_write_alloc (&buf,BLENZ (&src)); +struct buffer buf = work; +void *buf_p =buf_write_alloc (&buf,BLENZ (&src));ASSERT (buf_p);memcpy (buf_p,BPTR (&src),BLENZ (&src));
@@ -345,7 +344,6 @@struct buffer encrypt_workspace =alloc_buf_gc (BUF_SIZE (&frame), &gc);struct buffer decrypt_workspace =alloc_buf_gc (BUF_SIZE (&frame), &gc);struct buffer work =alloc_buf_gc (BUF_SIZE (&frame), &gc); -struct buffer buf =clear_buf ();struct buffer src =alloc_buf_gc (frame.buf.payload_size, &gc);void *buf_p;
@@ -360,7 +358,7 @@prng_bytes (BPTR (&src),BLEN (&src));/* copy source to input buf */ - buf = work; +struct buffer buf = work; buf_p =buf_write_alloc (&buf,BLENZ (&src));ASSERT (buf_p);memcpy (buf_p,BPTR (&src),BLENZ (&src));
@@ -641,7 +639,6 @@struct buffer work =alloc_buf_gc (BUF_SIZE (&frame), &gc);struct buffer encrypt_workspace =alloc_buf_gc (BUF_SIZE (&frame), &gc);struct buffer decrypt_workspace =alloc_buf_gc (BUF_SIZE (&frame), &gc); -struct buffer buf =clear_buf ();void *buf_p;/* init work */
@@ -658,7 +655,7 @@ASSERT (buf_write (&src, plaintext,strlen (plaintext)));/* copy source to input buf */ - buf = work; +struct buffer buf = work; buf_p =buf_write_alloc (&buf,BLENZ (&src));ASSERT (buf_p);memcpy (buf_p,BPTR (&src),BLENZ (&src));
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1617?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Id0caa497c4ff1ad8743cb23f332f003b2d3393ed
Gerrit-Change-Number: 1617
Gerrit-PatchSet: 20
Gerrit-Owner: flichtenheld <[email protected]>
Gerrit-Reviewer: plaisthos <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: stipa <[email protected]>
Gerrit-Attention: plaisthos <[email protected]>
Gerrit-Attention: stipa <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Attention is currently required from: flichtenheld, plaisthos, stipa.
razvanc has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1617?usp=email )
Change subject: Remove various useless assignments
......................................................................
Patch Set 21: Code-Review+2
(1 comment)
File src/openvpn/pkcs11_openssl.c:
http://gerrit.openvpn.net/c/openvpn/+/1617/comment/37bd7045_cd56a7b6?usp=email :
PS21, Line 187: sigalg.op = "Sign";
My cppcheck run also flagged this as an unreadVariable. Is it a false positive?
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1617?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Id0caa497c4ff1ad8743cb23f332f003b2d3393ed
Gerrit-Change-Number: 1617
Gerrit-PatchSet: 21
Gerrit-Owner: flichtenheld <[email protected]>
Gerrit-Reviewer: plaisthos <[email protected]>
Gerrit-Reviewer: razvanc <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: stipa <[email protected]>
Gerrit-Attention: plaisthos <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]>
Gerrit-Attention: stipa <[email protected]>
Gerrit-Comment-Date: Sat, 12 Sep 2026 17:54:45 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
PATCH v21 1/1 Remove various useless assignments
In reply to a message not in the archiveFrom: Frank Lichtenheld <[email protected]>
The values assigned by these are never actually used for something.
Identified by cppcheck.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1617
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1617
This mail reflects revision 21 of this Change.
Acked-by according to Gerrit (reflected above):
Razvan Cojocaru <[email protected]>
dev-tools/cppcheck-suppression +1 -4
@@ -5,9 +5,6 @@ constParameterPointer invalidPrintfArgType_sint invalidPrintfArgType_uint -redundantAssignment -redundantInitialization -unreadVariable unusedFunction usleepCalled variableScope
@@ -74,7 +71,7 @@ # IGN: strlen(NULL) is not nice code, but seems to work nullPointerRedundantCheck:src/openvpn/init.c:301 # FP: cppcheck doesn't understand ZeroMemory -redundantAssignment:src/openvpnserv/interactive.c:203 +redundantAssignment:src/openvpnserv/interactive.c:204 # IGN: We reuse the same variable name due to macro usage shadowVariable:src/openvpn/options.c:1948 shadowVariable:src/openvpn/options.c:1966
src/openvpn/console_builtin.c +5 -5
@@ -192,7 +192,6 @@static bool get_console_input (const char *prompt,const bool echo,char *input,const int capacity) { -bool ret = false;ASSERT (prompt);ASSERT (input);ASSERT (capacity >0 );
@@ -200,8 +199,11 @@#if defined(_WIN32)return get_console_input_win32 (prompt, echo, input, capacity); -#elif defined(HAVE_TERMIOS_H ) +#elif !defined(HAVE_TERMIOS_H ) +msg (M_FATAL ,"Sorry, but I can't get console input on this OS (%s)" , prompt); +#else bool restore_tty = false; +bool ret = false;struct termios tty_tmp, tty_save;/* did we --daemon'ize before asking for passwords?
@@ -258,10 +260,8 @@ }close_tty (fp); -#else /* if defined(_WIN32) */ -msg (M_FATAL ,"Sorry, but I can't get console input on this OS (%s)" , prompt); -#endif /* if defined(_WIN32) */ return ret; +#endif /* if defined(_WIN32) */ }/**
src/openvpn/crypto.c +2 -4
@@ -1204,8 +1204,6 @@struct buffer work =alloc_buf_gc (BUF_SIZE (frame), &gc);struct buffer encrypt_workspace =alloc_buf_gc (BUF_SIZE (frame), &gc);struct buffer decrypt_workspace =alloc_buf_gc (BUF_SIZE (frame), &gc); -struct buffer buf =clear_buf (); -void *buf_p;/* init work */ ASSERT (buf_init (&work, frame->buf.headroom));
@@ -1242,8 +1240,8 @@prng_bytes (BPTR (&src),BLEN (&src));/* copy source to input buf */ - buf = work; - buf_p =buf_write_alloc (&buf,BLENZ (&src)); +struct buffer buf = work; +void *buf_p =buf_write_alloc (&buf,BLENZ (&src));ASSERT (buf_p);memcpy (buf_p,BPTR (&src),BLENZ (&src));
src/openvpn/error.h +1 -1
@@ -408,8 +408,8 @@ openvpn_errno_maybe_crt(bool *crt_error) {int err =0 ; - *crt_error = false;#ifdef _WIN32 + *crt_error = false; err =GetLastError ();if (err ==ERROR_SUCCESS ) {
src/openvpn/forward.c +1 -2
@@ -1746,7 +1746,6 @@ process_outgoing_link(struct context *c, struct link_socket *sock) { struct gc_arena gc = gc_new(); -int error_code =0 ;if (c->c2.to_link.len >0 && c->c2.to_link.len <= c->c2.frame.buf.payload_size) {
@@ -1821,7 +1820,7 @@ }/* Check return status */ - error_code =openvpn_errno (); +int error_code =openvpn_errno ();check_status (size,"write" , sock,NULL );if (size >0 )
src/openvpn/manage.c +2 -3
@@ -916,10 +916,9 @@static void man_remote_entry_count (struct management *man) { -unsigned count =0 ;if (man->persist.callback.remote_entry_count) { - count = (*man->persist.callback.remote_entry_count)(man->persist.callback.arg); +unsigned int count = (*man->persist.callback.remote_entry_count)(man->persist.callback.arg);msg (M_CLIENT ,"%u" , count);msg (M_CLIENT ,"END" ); }
@@ -3742,7 +3741,6 @@struct gc_arena gc =gc_new ();int ret =0 ;volatile int signal_received =0 ; -struct buffer alert_msg =clear_buf ();const bool standalone_disabled_save = man->persist.standalone_disabled;struct man_connection *mc = &man->connection;
@@ -3754,6 +3752,7 @@ *state =EKS_SOLICIT ; +struct buffer alert_msg;if (b64_data) { alert_msg =alloc_buf_gc (strlen (b64_data) +strlen (prompt) +3 , &gc);
src/openvpn/options.c +1 -3
@@ -4157,8 +4157,7 @@bool key_is_external (const struct options *options) { -bool ret = false; - ret = ret || (options->management_flags &MF_EXTERNAL_KEY ); +bool ret = options->management_flags &MF_EXTERNAL_KEY ;#ifdef ENABLE_PKCS11 ret = ret || (options->pkcs11_providers[0 ] !=NULL );#endif
@@ -5697,7 +5696,6 @@if (streq (p[1 ],"FORWARD_COMPATIBLE" ) && p[2 ] &&streq (p[2 ],"1" )) { options->forward_compatible = true; - msglevel_fc =msglevel_forward_compatible (options, msglevel); }setenv_str (es, p[1 ], p[2 ] ? p[2 ] :"" ); }
src/openvpn/pkcs11.c +8 -8
@@ -80,6 +80,9 @@static msglvl_t _pkcs11_msg_pkcs112openvpn (const unsigned flags) { +#ifdef ENABLE_PKCS11_FORCE_DEBUG +return M_INFO ; +#else msglvl_t openvpn_flags; switch (flags)
@@ -109,16 +112,16 @@ break; } -#if defined(ENABLE_PKCS11_FORCE_DEBUG ) - openvpn_flags =M_INFO ; -#endif -return openvpn_flags; +#endif }static unsigned _pkcs11_msg_openvpn2pkcs11 (const msglvl_t flags) { +#ifdef ENABLE_PKCS11_FORCE_DEBUG +return PKCS11H_LOG_DEBUG2 ; +#else unsigned pkcs11_flags;if ((flags &D_PKCS11_DEBUG ) !=0 )
@@ -146,11 +149,8 @@ pkcs11_flags =PKCS11H_LOG_ERROR ; } -#if defined(ENABLE_PKCS11_FORCE_DEBUG ) - pkcs11_flags =PKCS11H_LOG_DEBUG2 ; -#endif -return pkcs11_flags; +#endif } static void
src/openvpn/pkcs11_openssl.c +0 -2
@@ -384,7 +384,6 @@if (certificate !=NULL ) {pkcs11h_certificate_freeCertificate (certificate); - certificate =NULL ; }/*
@@ -400,7 +399,6 @@if (openssl_session !=NULL ) {pkcs11h_openssl_freeSession (openssl_session); - openssl_session =NULL ; }return ret;#endif /* ifdef HAVE_XKEY_PROVIDER */
src/openvpn/push_util.c +3 -5
@@ -99,7 +99,6 @@ }char *str =gc_strdup (s, gc); -size_t i =0 ;while (*str) {
@@ -112,11 +111,11 @@/* if no commas were found go to fail, do not send any message */ return false; } +/* copy from current position to (ci - 1) */ str[ci] ='\0' ; -/* copy from i to (ci -1) */ struct buffer tmp =forge_msg (str,",push-continuation 2" , gc);buffer_list_push (msgs,BSTR (&tmp)); - i = ci +1 ; + str += ci +1 ; }else {
@@ -130,9 +129,8 @@struct buffer tmp =forge_msg (str,NULL , gc);buffer_list_push (msgs,BSTR (&tmp)); } - i =strlen (str); +break ; } - str = &str[i]; }return true; }
src/openvpn/socket.c +1 -1
@@ -753,7 +753,7 @@*/ socklen_t remote_len_af =af_addr_size (act->dest.addr.sa.sa_family);socklen_t remote_len =sizeof (act->dest.addr); -socket_descriptor_t new_sd =SOCKET_UNDEFINED ; +socket_descriptor_t new_sd;CLEAR (*act);
src/openvpn/ssl_openssl.c +4 -6
@@ -2283,13 +2283,13 @@ }int typeid =EVP_PKEY_id (pkey); + +#ifndef OPENSSL_NO_EC #if OPENSSL_VERSION_NUMBER <0x30000000L bool is_ec = typeid ==EVP_PKEY_EC ;#else bool is_ec =EVP_PKEY_is_a (pkey,"EC" );#endif - -#ifndef OPENSSL_NO_EC char groupname[64 ];if (is_ec) {
@@ -2593,15 +2593,13 @@ "builtin EC curves. It does not list additional curves nor X448 or X25519\n");#ifndef OPENSSL_NO_EC EC_builtin_curve *curves =NULL ; -size_t crv_len =0 ; -size_t n =0 ; - crv_len =EC_get_builtin_curves (NULL ,0 ); +size_t crv_len =EC_get_builtin_curves (NULL ,0 );ALLOC_ARRAY (curves, EC_builtin_curve, crv_len);if (EC_get_builtin_curves (curves, crv_len)) {printf ("\nAvailable Elliptic curves/groups:\n" ); -for (n =0 ; n < crv_len; n++) +for (size_t n =0 ; n < crv_len; n++) {const char *sname; sname =OBJ_nid2sn (curves[n].nid);
src/openvpn/win32.c +4 -3
@@ -1340,9 +1340,6 @@is_wow64_process2_t is_wow64_process2 = (is_wow64_process2_t )GetProcAddress (GetModuleHandle ("Kernel32.dll" ),"IsWow64Process2" ); -USHORT process_machine =0 ; -USHORT native_machine =0 ; -#ifdef _ARM64_ *process_arch =ARCH_ARM64 ;#elif defined(_WIN64)
@@ -1350,6 +1347,8 @@if (is_wow64_process2) {/* this could be amd64 on arm64 */ +USHORT process_machine =0 ; +USHORT native_machine =0 ;BOOL is_wow64 =is_wow64_process2 (GetCurrentProcess (), &process_machine, &native_machine);if (is_wow64 && native_machine ==IMAGE_FILE_MACHINE_ARM64 ) {
@@ -1362,6 +1361,8 @@if (is_wow64_process2) {/* check if we're running on arm64 or amd64 machine */ +USHORT process_machine =0 ; +USHORT native_machine =0 ;BOOL is_wow64 =is_wow64_process2 (GetCurrentProcess (), &process_machine, &native_machine);if (is_wow64) {
src/openvpnmsica/openvpnmsica.c +0 -1
@@ -711,7 +711,6 @@ uiResult =MsiViewFetch (hViewST, &hRecord);if (uiResult ==ERROR_NO_MORE_ITEMS ) { - uiResult =ERROR_SUCCESS ;break ; }else if (uiResult !=ERROR_SUCCESS )
src/tapctl/tap.c +2 -4
@@ -473,7 +473,7 @@return ERROR_OUTOFMEMORY ; } - dwCountExpResult =ExpandEnvironmentStrings (szValue, szValueExp, dwCountExp); +ExpandEnvironmentStrings (szValue, szValueExp, dwCountExp);free (szValue); *pszValue = szValueExp;return ERROR_SUCCESS ;
@@ -601,8 +601,6 @@ _In_ DWORD dwProperty, _Out_opt_ LPDWORD pdwPropertyRegDataType, _Out_ LPVOID *ppData) { - DWORD dwResult = ERROR_BAD_ARGUMENTS; - if (ppData == NULL) { return ERROR_BAD_ARGUMENTS;
@@ -628,7 +626,7 @@ }else { - dwResult =GetLastError (); +DWORD dwResult =GetLastError ();if (dwResult ==ERROR_INSUFFICIENT_BUFFER ) {/* Allocate on heap and retry. */
tests/unit_tests/openvpn/test_ssl.c +8 -11
@@ -217,7 +217,7 @@#if !defined(HAVE_OPENSSL_STORE )skip (); -#else /* HAVE_OPENSSL_STORE */ +#else /* HAVE_OPENSSL_STORE */ struct tls_root_ctx ctx = {0 };const char *certfile = global_state.certfile;
@@ -228,9 +228,10 @@struct buffer keyuri =alloc_buf_gc (6 +strlen (keyfile) +1 , gc);/* 6 bytes for "file:/" */ /* Windows temp file path starts with drive letter -- add a leading slash for URI */ -const char *lead ="" ;#ifdef _WIN32 - lead ="/" ; +const char *lead ="/" ; +#else +const char *lead ="" ;#endif /* _WIN32 */ assert_true (buf_printf (&certuri,"file:%s%s" , lead, certfile));assert_true (buf_printf (&keyuri,"file:%s%s" , lead, keyfile));
@@ -292,8 +293,6 @@struct buffer work =alloc_buf_gc (BUF_SIZE (&frame), &gc);struct buffer encrypt_workspace =alloc_buf_gc (BUF_SIZE (&frame), &gc);struct buffer decrypt_workspace =alloc_buf_gc (BUF_SIZE (&frame), &gc); -struct buffer buf =clear_buf (); -void *buf_p;/* init work */ ASSERT (buf_init (&work, frame.buf.headroom));
@@ -314,8 +313,8 @@prng_bytes (BPTR (&src),BLEN (&src));/* copy source to input buf */ - buf = work; - buf_p =buf_write_alloc (&buf,BLENZ (&src)); +struct buffer buf = work; +void *buf_p =buf_write_alloc (&buf,BLENZ (&src));ASSERT (buf_p);memcpy (buf_p,BPTR (&src),BLENZ (&src));
@@ -345,7 +344,6 @@struct buffer encrypt_workspace =alloc_buf_gc (BUF_SIZE (&frame), &gc);struct buffer decrypt_workspace =alloc_buf_gc (BUF_SIZE (&frame), &gc);struct buffer work =alloc_buf_gc (BUF_SIZE (&frame), &gc); -struct buffer buf =clear_buf ();struct buffer src =alloc_buf_gc (frame.buf.payload_size, &gc);void *buf_p;
@@ -360,7 +358,7 @@prng_bytes (BPTR (&src),BLEN (&src));/* copy source to input buf */ - buf = work; +struct buffer buf = work; buf_p =buf_write_alloc (&buf,BLENZ (&src));ASSERT (buf_p);memcpy (buf_p,BPTR (&src),BLENZ (&src));
@@ -641,7 +639,6 @@struct buffer work =alloc_buf_gc (BUF_SIZE (&frame), &gc);struct buffer encrypt_workspace =alloc_buf_gc (BUF_SIZE (&frame), &gc);struct buffer decrypt_workspace =alloc_buf_gc (BUF_SIZE (&frame), &gc); -struct buffer buf =clear_buf ();void *buf_p;/* init work */
@@ -658,7 +655,7 @@ASSERT (buf_write (&src, plaintext,strlen (plaintext)));/* copy source to input buf */ - buf = work; +struct buffer buf = work; buf_p =buf_write_alloc (&buf,BLENZ (&src));ASSERT (buf_p);memcpy (buf_p,BPTR (&src),BLENZ (&src));
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
[Openvpn-devel] [PATCH applied] Re: Remove various useless assignments
I did have some second thoughts about the push_utils.c change, but Razvan enlightened me ;-) - so this is not changing behaviour, not a bugfix, and correct code...
Stared at the changes - some of the bits are still ugly, like the code duplication for the windows version detection, but most of the changes are correct *and* improve code readability at the same time. Good stuff.
BB agrees that the result is still working ;-) (we had build fails, but those were - again - something-infrastructure failing random t_client tests. Restarting made them all succeed)
Your patch has been applied to the master branch.
commit a57e39923d55987336f544ce0c1b3b42c35f0ec0
Author: Frank Lichtenheld Date: Sat Sep 12 22:07:41 2026 +0200
Remove various useless assignments
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1617
Message-Id: <[email protected]>
URL: https://www.mail-archive.com/[email protected]/msg39142.html
--
kind regards,
Gert Doering
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Attention is currently required from: flichtenheld, plaisthos, stipa.
cron2 has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1617?usp=email )
Change subject: Remove various useless assignments
......................................................................
Patch Set 21: Code-Review-1
(1 comment)
File src/openvpn/push_util.c:
http://gerrit.openvpn.net/c/openvpn/+/1617/comment/48849d0e_8d7bdc20?usp=email :
PS21, Line 134: }
this is changing behaviour (because in the else {} branch we're no longer skipping something), **but** I think this is actually buggy before, namely, loosing one option when push-continuation needs to be set. Right? So this is fine, but should be mentioned in the commit message.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1617?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Id0caa497c4ff1ad8743cb23f332f003b2d3393ed
Gerrit-Change-Number: 1617
Gerrit-PatchSet: 21
Gerrit-Owner: flichtenheld <[email protected]>
Gerrit-Reviewer: cron2 <[email protected]>
Gerrit-Reviewer: plaisthos <[email protected]>
Gerrit-Reviewer: razvanc <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: stipa <[email protected]>
Gerrit-Attention: plaisthos <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]>
Gerrit-Attention: stipa <[email protected]>
Gerrit-Comment-Date: Sun, 13 Sep 2026 09:45:07 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Attention is currently required from: flichtenheld, plaisthos, stipa.
razvanc has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1617?usp=email )
Change subject: Remove various useless assignments
......................................................................
Patch Set 21:
(1 comment)
File src/openvpn/push_util.c:
http://gerrit.openvpn.net/c/openvpn/+/1617/comment/964dc425_b42707d9?usp=email :
PS21, Line 134: }
Quoted 1 line
this is changing behaviour (because in the
else {}branch we're no longer skipping something), **b […]
It is not changing behavior. The else branch did this:
``` i = strlen(str); // this puts str square on its NUL-terminator ``` then: ``` str = &str[i]; // next while (*str) will fail and the loop ends ```
So Frank's new code is exactly equivalent (and arguably clearer).
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1617?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Id0caa497c4ff1ad8743cb23f332f003b2d3393ed
Gerrit-Change-Number: 1617
Gerrit-PatchSet: 21
Gerrit-Owner: flichtenheld <[email protected]>
Gerrit-Reviewer: cron2 <[email protected]>
Gerrit-Reviewer: plaisthos <[email protected]>
Gerrit-Reviewer: razvanc <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: stipa <[email protected]>
Gerrit-Attention: plaisthos <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]>
Gerrit-Attention: stipa <[email protected]>
Gerrit-Comment-Date: Sun, 13 Sep 2026 09:52:04 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: cron2 <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Attention is currently required from: flichtenheld, plaisthos, stipa.
cron2 has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1617?usp=email )
Change subject: Remove various useless assignments
......................................................................
Patch Set 21: -Code-Review
(1 comment)
File src/openvpn/push_util.c:
http://gerrit.openvpn.net/c/openvpn/+/1617/comment/1e30ed79_80442e61?usp=email :
PS21, Line 134: }
Quoted 1 line
It is not changing behavior. The
elsebranch did this: […]
Thanks. I only saw the "str is not advanced here, so this is different" part, but missed the "the loop will implicitly be broken in the else {} case" bit.
So yes, this makes sense. Will progress.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1617?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Id0caa497c4ff1ad8743cb23f332f003b2d3393ed
Gerrit-Change-Number: 1617
Gerrit-PatchSet: 21
Gerrit-Owner: flichtenheld <[email protected]>
Gerrit-Reviewer: cron2 <[email protected]>
Gerrit-Reviewer: plaisthos <[email protected]>
Gerrit-Reviewer: razvanc <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: stipa <[email protected]>
Gerrit-Attention: plaisthos <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]>
Gerrit-Attention: stipa <[email protected]>
Gerrit-Comment-Date: Sun, 13 Sep 2026 10:02:48 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: cron2 <[email protected]>
Comment-In-Reply-To: razvanc <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Attention is currently required from: flichtenheld, plaisthos, stipa.
cron2 has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1617?usp=email )
Change subject: Remove various useless assignments
......................................................................
Patch Set 21:
(1 comment)
File src/openvpn/push_util.c:
http://gerrit.openvpn.net/c/openvpn/+/1617/comment/e2d50c38_80690193?usp=email :
PS21, Line 134: }
Quoted 1 line
Thanks. […]
Done
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1617?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Id0caa497c4ff1ad8743cb23f332f003b2d3393ed
Gerrit-Change-Number: 1617
Gerrit-PatchSet: 21
Gerrit-Owner: flichtenheld <[email protected]>
Gerrit-Reviewer: cron2 <[email protected]>
Gerrit-Reviewer: plaisthos <[email protected]>
Gerrit-Reviewer: razvanc <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: stipa <[email protected]>
Gerrit-Attention: plaisthos <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]>
Gerrit-Attention: stipa <[email protected]>
Gerrit-Comment-Date: Sun, 13 Sep 2026 10:03:00 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: cron2 <[email protected]>
Comment-In-Reply-To: razvanc <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
cron2 has uploaded a new patch set (#22) to the change originally created by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1617?usp=email )
The following approvals got outdated and were removed:
Code-Review+2 by razvanc
Change subject: Remove various useless assignments
......................................................................
Remove various useless assignments
The values assigned by these are never actually used for something.
Identified by cppcheck.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1617
Message-Id: <[email protected]>
URL: https://www.mail-archive.com/[email protected]/msg39142.html
---
M dev-tools/cppcheck-suppression
M src/openvpn/console_builtin.c
M src/openvpn/crypto.c
M src/openvpn/error.h
M src/openvpn/forward.c
M src/openvpn/manage.c
M src/openvpn/options.c
M src/openvpn/pkcs11.c
M src/openvpn/pkcs11_openssl.c
M src/openvpn/push_util.c
M src/openvpn/socket.c
M src/openvpn/ssl_openssl.c
M src/openvpn/win32.c
M src/openvpnmsica/openvpnmsica.c
M src/tapctl/tap.c
M tests/unit_tests/openvpn/test_ssl.c
16 files changed, 43 insertions(+), 63 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/17/1617/22
dev-tools/cppcheck-suppression +1 -4
@@ -5,9 +5,6 @@ constParameterPointer invalidPrintfArgType_sint invalidPrintfArgType_uint -redundantAssignment -redundantInitialization -unreadVariable unusedFunction usleepCalled variableScope
@@ -74,7 +71,7 @@ # IGN: strlen(NULL) is not nice code, but seems to work nullPointerRedundantCheck:src/openvpn/init.c:301 # FP: cppcheck doesn't understand ZeroMemory -redundantAssignment:src/openvpnserv/interactive.c:203 +redundantAssignment:src/openvpnserv/interactive.c:204 # IGN: We reuse the same variable name due to macro usage shadowVariable:src/openvpn/options.c:1948 shadowVariable:src/openvpn/options.c:1966
src/openvpn/console_builtin.c +5 -5
@@ -192,7 +192,6 @@static bool get_console_input (const char *prompt,const bool echo,char *input,const int capacity) { -bool ret = false;ASSERT (prompt);ASSERT (input);ASSERT (capacity >0 );
@@ -200,8 +199,11 @@#if defined(_WIN32)return get_console_input_win32 (prompt, echo, input, capacity); -#elif defined(HAVE_TERMIOS_H ) +#elif !defined(HAVE_TERMIOS_H ) +msg (M_FATAL ,"Sorry, but I can't get console input on this OS (%s)" , prompt); +#else bool restore_tty = false; +bool ret = false;struct termios tty_tmp, tty_save;/* did we --daemon'ize before asking for passwords?
@@ -258,10 +260,8 @@ }close_tty (fp); -#else /* if defined(_WIN32) */ -msg (M_FATAL ,"Sorry, but I can't get console input on this OS (%s)" , prompt); -#endif /* if defined(_WIN32) */ return ret; +#endif /* if defined(_WIN32) */ }/**
src/openvpn/crypto.c +2 -4
@@ -1204,8 +1204,6 @@struct buffer work =alloc_buf_gc (BUF_SIZE (frame), &gc);struct buffer encrypt_workspace =alloc_buf_gc (BUF_SIZE (frame), &gc);struct buffer decrypt_workspace =alloc_buf_gc (BUF_SIZE (frame), &gc); -struct buffer buf =clear_buf (); -void *buf_p;/* init work */ ASSERT (buf_init (&work, frame->buf.headroom));
@@ -1242,8 +1240,8 @@prng_bytes (BPTR (&src),BLEN (&src));/* copy source to input buf */ - buf = work; - buf_p =buf_write_alloc (&buf,BLENZ (&src)); +struct buffer buf = work; +void *buf_p =buf_write_alloc (&buf,BLENZ (&src));ASSERT (buf_p);memcpy (buf_p,BPTR (&src),BLENZ (&src));
src/openvpn/error.h +1 -1
@@ -408,8 +408,8 @@ openvpn_errno_maybe_crt(bool *crt_error) {int err =0 ; - *crt_error = false;#ifdef _WIN32 + *crt_error = false; err =GetLastError ();if (err ==ERROR_SUCCESS ) {
src/openvpn/forward.c +1 -2
@@ -1746,7 +1746,6 @@ process_outgoing_link(struct context *c, struct link_socket *sock) { struct gc_arena gc = gc_new(); -int error_code =0 ;if (c->c2.to_link.len >0 && c->c2.to_link.len <= c->c2.frame.buf.payload_size) {
@@ -1821,7 +1820,7 @@ }/* Check return status */ - error_code =openvpn_errno (); +int error_code =openvpn_errno ();check_status (size,"write" , sock,NULL );if (size >0 )
src/openvpn/manage.c +2 -3
@@ -916,10 +916,9 @@static void man_remote_entry_count (struct management *man) { -unsigned count =0 ;if (man->persist.callback.remote_entry_count) { - count = (*man->persist.callback.remote_entry_count)(man->persist.callback.arg); +unsigned int count = (*man->persist.callback.remote_entry_count)(man->persist.callback.arg);msg (M_CLIENT ,"%u" , count);msg (M_CLIENT ,"END" ); }
@@ -3743,7 +3742,6 @@struct gc_arena gc =gc_new ();int ret =0 ;volatile int signal_received =0 ; -struct buffer alert_msg =clear_buf ();const bool standalone_disabled_save = man->persist.standalone_disabled;struct man_connection *mc = &man->connection;
@@ -3755,6 +3753,7 @@ *state =EKS_SOLICIT ; +struct buffer alert_msg;if (b64_data) { alert_msg =alloc_buf_gc (strlen (b64_data) +strlen (prompt) +3 , &gc);
src/openvpn/options.c +1 -3
@@ -4157,8 +4157,7 @@bool key_is_external (const struct options *options) { -bool ret = false; - ret = ret || (options->management_flags &MF_EXTERNAL_KEY ); +bool ret = options->management_flags &MF_EXTERNAL_KEY ;#ifdef ENABLE_PKCS11 ret = ret || (options->pkcs11_providers[0 ] !=NULL );#endif
@@ -5697,7 +5696,6 @@if (streq (p[1 ],"FORWARD_COMPATIBLE" ) && p[2 ] &&streq (p[2 ],"1" )) { options->forward_compatible = true; - msglevel_fc =msglevel_forward_compatible (options, msglevel); }setenv_str (es, p[1 ], p[2 ] ? p[2 ] :"" ); }
src/openvpn/pkcs11.c +8 -8
@@ -80,6 +80,9 @@static msglvl_t _pkcs11_msg_pkcs112openvpn (const unsigned flags) { +#ifdef ENABLE_PKCS11_FORCE_DEBUG +return M_INFO ; +#else msglvl_t openvpn_flags; switch (flags)
@@ -109,16 +112,16 @@ break; } -#if defined(ENABLE_PKCS11_FORCE_DEBUG ) - openvpn_flags =M_INFO ; -#endif -return openvpn_flags; +#endif }static unsigned _pkcs11_msg_openvpn2pkcs11 (const msglvl_t flags) { +#ifdef ENABLE_PKCS11_FORCE_DEBUG +return PKCS11H_LOG_DEBUG2 ; +#else unsigned pkcs11_flags;if ((flags &D_PKCS11_DEBUG ) !=0 )
@@ -146,11 +149,8 @@ pkcs11_flags =PKCS11H_LOG_ERROR ; } -#if defined(ENABLE_PKCS11_FORCE_DEBUG ) - pkcs11_flags =PKCS11H_LOG_DEBUG2 ; -#endif -return pkcs11_flags; +#endif } static void
src/openvpn/pkcs11_openssl.c +0 -2
@@ -384,7 +384,6 @@if (certificate !=NULL ) {pkcs11h_certificate_freeCertificate (certificate); - certificate =NULL ; }/*
@@ -400,7 +399,6 @@if (openssl_session !=NULL ) {pkcs11h_openssl_freeSession (openssl_session); - openssl_session =NULL ; }return ret;#endif /* ifdef HAVE_XKEY_PROVIDER */
src/openvpn/push_util.c +3 -5
@@ -99,7 +99,6 @@ }char *str =gc_strdup (s, gc); -size_t i =0 ;while (*str) {
@@ -112,11 +111,11 @@/* if no commas were found go to fail, do not send any message */ return false; } +/* copy from current position to (ci - 1) */ str[ci] ='\0' ; -/* copy from i to (ci -1) */ struct buffer tmp =forge_msg (str,",push-continuation 2" , gc);buffer_list_push (msgs,BSTR (&tmp)); - i = ci +1 ; + str += ci +1 ; }else {
@@ -130,9 +129,8 @@struct buffer tmp =forge_msg (str,NULL , gc);buffer_list_push (msgs,BSTR (&tmp)); } - i =strlen (str); +break ; } - str = &str[i]; }return true; }
src/openvpn/socket.c +1 -1
@@ -790,7 +790,7 @@*/ socklen_t remote_len_af =af_addr_size (act->dest.addr.sa.sa_family);socklen_t remote_len =sizeof (act->dest.addr); -socket_descriptor_t new_sd =SOCKET_UNDEFINED ; +socket_descriptor_t new_sd;CLEAR (*act);
src/openvpn/ssl_openssl.c +4 -6
@@ -2283,13 +2283,13 @@ }int typeid =EVP_PKEY_id (pkey); + +#ifndef OPENSSL_NO_EC #if OPENSSL_VERSION_NUMBER <0x30000000L bool is_ec = typeid ==EVP_PKEY_EC ;#else bool is_ec =EVP_PKEY_is_a (pkey,"EC" );#endif - -#ifndef OPENSSL_NO_EC char groupname[64 ];if (is_ec) {
@@ -2593,15 +2593,13 @@ "builtin EC curves. It does not list additional curves nor X448 or X25519\n");#ifndef OPENSSL_NO_EC EC_builtin_curve *curves =NULL ; -size_t crv_len =0 ; -size_t n =0 ; - crv_len =EC_get_builtin_curves (NULL ,0 ); +size_t crv_len =EC_get_builtin_curves (NULL ,0 );ALLOC_ARRAY (curves, EC_builtin_curve, crv_len);if (EC_get_builtin_curves (curves, crv_len)) {printf ("\nAvailable Elliptic curves/groups:\n" ); -for (n =0 ; n < crv_len; n++) +for (size_t n =0 ; n < crv_len; n++) {const char *sname; sname =OBJ_nid2sn (curves[n].nid);
src/openvpn/win32.c +4 -3
@@ -1340,9 +1340,6 @@is_wow64_process2_t is_wow64_process2 = (is_wow64_process2_t )GetProcAddress (GetModuleHandle ("Kernel32.dll" ),"IsWow64Process2" ); -USHORT process_machine =0 ; -USHORT native_machine =0 ; -#ifdef _ARM64_ *process_arch =ARCH_ARM64 ;#elif defined(_WIN64)
@@ -1350,6 +1347,8 @@if (is_wow64_process2) {/* this could be amd64 on arm64 */ +USHORT process_machine =0 ; +USHORT native_machine =0 ;BOOL is_wow64 =is_wow64_process2 (GetCurrentProcess (), &process_machine, &native_machine);if (is_wow64 && native_machine ==IMAGE_FILE_MACHINE_ARM64 ) {
@@ -1362,6 +1361,8 @@if (is_wow64_process2) {/* check if we're running on arm64 or amd64 machine */ +USHORT process_machine =0 ; +USHORT native_machine =0 ;BOOL is_wow64 =is_wow64_process2 (GetCurrentProcess (), &process_machine, &native_machine);if (is_wow64) {
src/openvpnmsica/openvpnmsica.c +0 -1
@@ -711,7 +711,6 @@ uiResult =MsiViewFetch (hViewST, &hRecord);if (uiResult ==ERROR_NO_MORE_ITEMS ) { - uiResult =ERROR_SUCCESS ;break ; }else if (uiResult !=ERROR_SUCCESS )
src/tapctl/tap.c +2 -4
@@ -473,7 +473,7 @@return ERROR_OUTOFMEMORY ; } - dwCountExpResult =ExpandEnvironmentStrings (szValue, szValueExp, dwCountExp); +ExpandEnvironmentStrings (szValue, szValueExp, dwCountExp);free (szValue); *pszValue = szValueExp;return ERROR_SUCCESS ;
@@ -601,8 +601,6 @@ _In_ DWORD dwProperty, _Out_opt_ LPDWORD pdwPropertyRegDataType, _Out_ LPVOID *ppData) { - DWORD dwResult = ERROR_BAD_ARGUMENTS; - if (ppData == NULL) { return ERROR_BAD_ARGUMENTS;
@@ -628,7 +626,7 @@ }else { - dwResult =GetLastError (); +DWORD dwResult =GetLastError ();if (dwResult ==ERROR_INSUFFICIENT_BUFFER ) {/* Allocate on heap and retry. */
tests/unit_tests/openvpn/test_ssl.c +8 -11
@@ -217,7 +217,7 @@#if !defined(HAVE_OPENSSL_STORE )skip (); -#else /* HAVE_OPENSSL_STORE */ +#else /* HAVE_OPENSSL_STORE */ struct tls_root_ctx ctx = {0 };const char *certfile = global_state.certfile;
@@ -228,9 +228,10 @@struct buffer keyuri =alloc_buf_gc (6 +strlen (keyfile) +1 , gc);/* 6 bytes for "file:/" */ /* Windows temp file path starts with drive letter -- add a leading slash for URI */ -const char *lead ="" ;#ifdef _WIN32 - lead ="/" ; +const char *lead ="/" ; +#else +const char *lead ="" ;#endif /* _WIN32 */ assert_true (buf_printf (&certuri,"file:%s%s" , lead, certfile));assert_true (buf_printf (&keyuri,"file:%s%s" , lead, keyfile));
@@ -292,8 +293,6 @@struct buffer work =alloc_buf_gc (BUF_SIZE (&frame), &gc);struct buffer encrypt_workspace =alloc_buf_gc (BUF_SIZE (&frame), &gc);struct buffer decrypt_workspace =alloc_buf_gc (BUF_SIZE (&frame), &gc); -struct buffer buf =clear_buf (); -void *buf_p;/* init work */ ASSERT (buf_init (&work, frame.buf.headroom));
@@ -314,8 +313,8 @@prng_bytes (BPTR (&src),BLEN (&src));/* copy source to input buf */ - buf = work; - buf_p =buf_write_alloc (&buf,BLENZ (&src)); +struct buffer buf = work; +void *buf_p =buf_write_alloc (&buf,BLENZ (&src));ASSERT (buf_p);memcpy (buf_p,BPTR (&src),BLENZ (&src));
@@ -345,7 +344,6 @@struct buffer encrypt_workspace =alloc_buf_gc (BUF_SIZE (&frame), &gc);struct buffer decrypt_workspace =alloc_buf_gc (BUF_SIZE (&frame), &gc);struct buffer work =alloc_buf_gc (BUF_SIZE (&frame), &gc); -struct buffer buf =clear_buf ();struct buffer src =alloc_buf_gc (frame.buf.payload_size, &gc);void *buf_p;
@@ -360,7 +358,7 @@prng_bytes (BPTR (&src),BLEN (&src));/* copy source to input buf */ - buf = work; +struct buffer buf = work; buf_p =buf_write_alloc (&buf,BLENZ (&src));ASSERT (buf_p);memcpy (buf_p,BPTR (&src),BLENZ (&src));
@@ -641,7 +639,6 @@struct buffer work =alloc_buf_gc (BUF_SIZE (&frame), &gc);struct buffer encrypt_workspace =alloc_buf_gc (BUF_SIZE (&frame), &gc);struct buffer decrypt_workspace =alloc_buf_gc (BUF_SIZE (&frame), &gc); -struct buffer buf =clear_buf ();void *buf_p;/* init work */
@@ -658,7 +655,7 @@ASSERT (buf_write (&src, plaintext,strlen (plaintext)));/* copy source to input buf */ - buf = work; +struct buffer buf = work; buf_p =buf_write_alloc (&buf,BLENZ (&src));ASSERT (buf_p);memcpy (buf_p,BPTR (&src),BLENZ (&src));
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1617?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Id0caa497c4ff1ad8743cb23f332f003b2d3393ed
Gerrit-Change-Number: 1617
Gerrit-PatchSet: 22
Gerrit-Owner: flichtenheld <[email protected]>
Gerrit-Reviewer: cron2 <[email protected]>
Gerrit-Reviewer: plaisthos <[email protected]>
Gerrit-Reviewer: razvanc <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: stipa <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1617?usp=email )
Change subject: Remove various useless assignments
......................................................................
Remove various useless assignments
The values assigned by these are never actually used for something.
Identified by cppcheck.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1617
Message-Id: <[email protected]>
URL: https://www.mail-archive.com/[email protected]/msg39142.html
---
M dev-tools/cppcheck-suppression
M src/openvpn/console_builtin.c
M src/openvpn/crypto.c
M src/openvpn/error.h
M src/openvpn/forward.c
M src/openvpn/manage.c
M src/openvpn/options.c
M src/openvpn/pkcs11.c
M src/openvpn/pkcs11_openssl.c
M src/openvpn/push_util.c
M src/openvpn/socket.c
M src/openvpn/ssl_openssl.c
M src/openvpn/win32.c
M src/openvpnmsica/openvpnmsica.c
M src/tapctl/tap.c
M tests/unit_tests/openvpn/test_ssl.c
16 files changed, 43 insertions(+), 63 deletions(-)
dev-tools/cppcheck-suppression +1 -4
@@ -5,9 +5,6 @@ constParameterPointer invalidPrintfArgType_sint invalidPrintfArgType_uint -redundantAssignment -redundantInitialization -unreadVariable unusedFunction usleepCalled variableScope
@@ -74,7 +71,7 @@ # IGN: strlen(NULL) is not nice code, but seems to work nullPointerRedundantCheck:src/openvpn/init.c:301 # FP: cppcheck doesn't understand ZeroMemory -redundantAssignment:src/openvpnserv/interactive.c:203 +redundantAssignment:src/openvpnserv/interactive.c:204 # IGN: We reuse the same variable name due to macro usage shadowVariable:src/openvpn/options.c:1948 shadowVariable:src/openvpn/options.c:1966
src/openvpn/console_builtin.c +5 -5
@@ -192,7 +192,6 @@static bool get_console_input (const char *prompt,const bool echo,char *input,const int capacity) { -bool ret = false;ASSERT (prompt);ASSERT (input);ASSERT (capacity >0 );
@@ -200,8 +199,11 @@#if defined(_WIN32)return get_console_input_win32 (prompt, echo, input, capacity); -#elif defined(HAVE_TERMIOS_H ) +#elif !defined(HAVE_TERMIOS_H ) +msg (M_FATAL ,"Sorry, but I can't get console input on this OS (%s)" , prompt); +#else bool restore_tty = false; +bool ret = false;struct termios tty_tmp, tty_save;/* did we --daemon'ize before asking for passwords?
@@ -258,10 +260,8 @@ }close_tty (fp); -#else /* if defined(_WIN32) */ -msg (M_FATAL ,"Sorry, but I can't get console input on this OS (%s)" , prompt); -#endif /* if defined(_WIN32) */ return ret; +#endif /* if defined(_WIN32) */ }/**
src/openvpn/crypto.c +2 -4
@@ -1204,8 +1204,6 @@struct buffer work =alloc_buf_gc (BUF_SIZE (frame), &gc);struct buffer encrypt_workspace =alloc_buf_gc (BUF_SIZE (frame), &gc);struct buffer decrypt_workspace =alloc_buf_gc (BUF_SIZE (frame), &gc); -struct buffer buf =clear_buf (); -void *buf_p;/* init work */ ASSERT (buf_init (&work, frame->buf.headroom));
@@ -1242,8 +1240,8 @@prng_bytes (BPTR (&src),BLEN (&src));/* copy source to input buf */ - buf = work; - buf_p =buf_write_alloc (&buf,BLENZ (&src)); +struct buffer buf = work; +void *buf_p =buf_write_alloc (&buf,BLENZ (&src));ASSERT (buf_p);memcpy (buf_p,BPTR (&src),BLENZ (&src));
src/openvpn/error.h +1 -1
@@ -408,8 +408,8 @@ openvpn_errno_maybe_crt(bool *crt_error) {int err =0 ; - *crt_error = false;#ifdef _WIN32 + *crt_error = false; err =GetLastError ();if (err ==ERROR_SUCCESS ) {
src/openvpn/forward.c +1 -2
@@ -1746,7 +1746,6 @@ process_outgoing_link(struct context *c, struct link_socket *sock) { struct gc_arena gc = gc_new(); -int error_code =0 ;if (c->c2.to_link.len >0 && c->c2.to_link.len <= c->c2.frame.buf.payload_size) {
@@ -1821,7 +1820,7 @@ }/* Check return status */ - error_code =openvpn_errno (); +int error_code =openvpn_errno ();check_status (size,"write" , sock,NULL );if (size >0 )
src/openvpn/manage.c +2 -3
@@ -916,10 +916,9 @@static void man_remote_entry_count (struct management *man) { -unsigned count =0 ;if (man->persist.callback.remote_entry_count) { - count = (*man->persist.callback.remote_entry_count)(man->persist.callback.arg); +unsigned int count = (*man->persist.callback.remote_entry_count)(man->persist.callback.arg);msg (M_CLIENT ,"%u" , count);msg (M_CLIENT ,"END" ); }
@@ -3743,7 +3742,6 @@struct gc_arena gc =gc_new ();int ret =0 ;volatile int signal_received =0 ; -struct buffer alert_msg =clear_buf ();const bool standalone_disabled_save = man->persist.standalone_disabled;struct man_connection *mc = &man->connection;
@@ -3755,6 +3753,7 @@ *state =EKS_SOLICIT ; +struct buffer alert_msg;if (b64_data) { alert_msg =alloc_buf_gc (strlen (b64_data) +strlen (prompt) +3 , &gc);
src/openvpn/options.c +1 -3
@@ -4157,8 +4157,7 @@bool key_is_external (const struct options *options) { -bool ret = false; - ret = ret || (options->management_flags &MF_EXTERNAL_KEY ); +bool ret = options->management_flags &MF_EXTERNAL_KEY ;#ifdef ENABLE_PKCS11 ret = ret || (options->pkcs11_providers[0 ] !=NULL );#endif
@@ -5697,7 +5696,6 @@if (streq (p[1 ],"FORWARD_COMPATIBLE" ) && p[2 ] &&streq (p[2 ],"1" )) { options->forward_compatible = true; - msglevel_fc =msglevel_forward_compatible (options, msglevel); }setenv_str (es, p[1 ], p[2 ] ? p[2 ] :"" ); }
src/openvpn/pkcs11.c +8 -8
@@ -80,6 +80,9 @@static msglvl_t _pkcs11_msg_pkcs112openvpn (const unsigned flags) { +#ifdef ENABLE_PKCS11_FORCE_DEBUG +return M_INFO ; +#else msglvl_t openvpn_flags; switch (flags)
@@ -109,16 +112,16 @@ break; } -#if defined(ENABLE_PKCS11_FORCE_DEBUG ) - openvpn_flags =M_INFO ; -#endif -return openvpn_flags; +#endif }static unsigned _pkcs11_msg_openvpn2pkcs11 (const msglvl_t flags) { +#ifdef ENABLE_PKCS11_FORCE_DEBUG +return PKCS11H_LOG_DEBUG2 ; +#else unsigned pkcs11_flags;if ((flags &D_PKCS11_DEBUG ) !=0 )
@@ -146,11 +149,8 @@ pkcs11_flags =PKCS11H_LOG_ERROR ; } -#if defined(ENABLE_PKCS11_FORCE_DEBUG ) - pkcs11_flags =PKCS11H_LOG_DEBUG2 ; -#endif -return pkcs11_flags; +#endif } static void
src/openvpn/pkcs11_openssl.c +0 -2
@@ -384,7 +384,6 @@if (certificate !=NULL ) {pkcs11h_certificate_freeCertificate (certificate); - certificate =NULL ; }/*
@@ -400,7 +399,6 @@if (openssl_session !=NULL ) {pkcs11h_openssl_freeSession (openssl_session); - openssl_session =NULL ; }return ret;#endif /* ifdef HAVE_XKEY_PROVIDER */
src/openvpn/push_util.c +3 -5
@@ -99,7 +99,6 @@ }char *str =gc_strdup (s, gc); -size_t i =0 ;while (*str) {
@@ -112,11 +111,11 @@/* if no commas were found go to fail, do not send any message */ return false; } +/* copy from current position to (ci - 1) */ str[ci] ='\0' ; -/* copy from i to (ci -1) */ struct buffer tmp =forge_msg (str,",push-continuation 2" , gc);buffer_list_push (msgs,BSTR (&tmp)); - i = ci +1 ; + str += ci +1 ; }else {
@@ -130,9 +129,8 @@struct buffer tmp =forge_msg (str,NULL , gc);buffer_list_push (msgs,BSTR (&tmp)); } - i =strlen (str); +break ; } - str = &str[i]; }return true; }
src/openvpn/socket.c +1 -1
@@ -790,7 +790,7 @@*/ socklen_t remote_len_af =af_addr_size (act->dest.addr.sa.sa_family);socklen_t remote_len =sizeof (act->dest.addr); -socket_descriptor_t new_sd =SOCKET_UNDEFINED ; +socket_descriptor_t new_sd;CLEAR (*act);
src/openvpn/ssl_openssl.c +4 -6
@@ -2283,13 +2283,13 @@ }int typeid =EVP_PKEY_id (pkey); + +#ifndef OPENSSL_NO_EC #if OPENSSL_VERSION_NUMBER <0x30000000L bool is_ec = typeid ==EVP_PKEY_EC ;#else bool is_ec =EVP_PKEY_is_a (pkey,"EC" );#endif - -#ifndef OPENSSL_NO_EC char groupname[64 ];if (is_ec) {
@@ -2593,15 +2593,13 @@ "builtin EC curves. It does not list additional curves nor X448 or X25519\n");#ifndef OPENSSL_NO_EC EC_builtin_curve *curves =NULL ; -size_t crv_len =0 ; -size_t n =0 ; - crv_len =EC_get_builtin_curves (NULL ,0 ); +size_t crv_len =EC_get_builtin_curves (NULL ,0 );ALLOC_ARRAY (curves, EC_builtin_curve, crv_len);if (EC_get_builtin_curves (curves, crv_len)) {printf ("\nAvailable Elliptic curves/groups:\n" ); -for (n =0 ; n < crv_len; n++) +for (size_t n =0 ; n < crv_len; n++) {const char *sname; sname =OBJ_nid2sn (curves[n].nid);
src/openvpn/win32.c +4 -3
@@ -1340,9 +1340,6 @@is_wow64_process2_t is_wow64_process2 = (is_wow64_process2_t )GetProcAddress (GetModuleHandle ("Kernel32.dll" ),"IsWow64Process2" ); -USHORT process_machine =0 ; -USHORT native_machine =0 ; -#ifdef _ARM64_ *process_arch =ARCH_ARM64 ;#elif defined(_WIN64)
@@ -1350,6 +1347,8 @@if (is_wow64_process2) {/* this could be amd64 on arm64 */ +USHORT process_machine =0 ; +USHORT native_machine =0 ;BOOL is_wow64 =is_wow64_process2 (GetCurrentProcess (), &process_machine, &native_machine);if (is_wow64 && native_machine ==IMAGE_FILE_MACHINE_ARM64 ) {
@@ -1362,6 +1361,8 @@if (is_wow64_process2) {/* check if we're running on arm64 or amd64 machine */ +USHORT process_machine =0 ; +USHORT native_machine =0 ;BOOL is_wow64 =is_wow64_process2 (GetCurrentProcess (), &process_machine, &native_machine);if (is_wow64) {
src/openvpnmsica/openvpnmsica.c +0 -1
@@ -711,7 +711,6 @@ uiResult =MsiViewFetch (hViewST, &hRecord);if (uiResult ==ERROR_NO_MORE_ITEMS ) { - uiResult =ERROR_SUCCESS ;break ; }else if (uiResult !=ERROR_SUCCESS )
src/tapctl/tap.c +2 -4
@@ -473,7 +473,7 @@return ERROR_OUTOFMEMORY ; } - dwCountExpResult =ExpandEnvironmentStrings (szValue, szValueExp, dwCountExp); +ExpandEnvironmentStrings (szValue, szValueExp, dwCountExp);free (szValue); *pszValue = szValueExp;return ERROR_SUCCESS ;
@@ -601,8 +601,6 @@ _In_ DWORD dwProperty, _Out_opt_ LPDWORD pdwPropertyRegDataType, _Out_ LPVOID *ppData) { - DWORD dwResult = ERROR_BAD_ARGUMENTS; - if (ppData == NULL) { return ERROR_BAD_ARGUMENTS;
@@ -628,7 +626,7 @@ }else { - dwResult =GetLastError (); +DWORD dwResult =GetLastError ();if (dwResult ==ERROR_INSUFFICIENT_BUFFER ) {/* Allocate on heap and retry. */
tests/unit_tests/openvpn/test_ssl.c +8 -11
@@ -217,7 +217,7 @@#if !defined(HAVE_OPENSSL_STORE )skip (); -#else /* HAVE_OPENSSL_STORE */ +#else /* HAVE_OPENSSL_STORE */ struct tls_root_ctx ctx = {0 };const char *certfile = global_state.certfile;
@@ -228,9 +228,10 @@struct buffer keyuri =alloc_buf_gc (6 +strlen (keyfile) +1 , gc);/* 6 bytes for "file:/" */ /* Windows temp file path starts with drive letter -- add a leading slash for URI */ -const char *lead ="" ;#ifdef _WIN32 - lead ="/" ; +const char *lead ="/" ; +#else +const char *lead ="" ;#endif /* _WIN32 */ assert_true (buf_printf (&certuri,"file:%s%s" , lead, certfile));assert_true (buf_printf (&keyuri,"file:%s%s" , lead, keyfile));
@@ -292,8 +293,6 @@struct buffer work =alloc_buf_gc (BUF_SIZE (&frame), &gc);struct buffer encrypt_workspace =alloc_buf_gc (BUF_SIZE (&frame), &gc);struct buffer decrypt_workspace =alloc_buf_gc (BUF_SIZE (&frame), &gc); -struct buffer buf =clear_buf (); -void *buf_p;/* init work */ ASSERT (buf_init (&work, frame.buf.headroom));
@@ -314,8 +313,8 @@prng_bytes (BPTR (&src),BLEN (&src));/* copy source to input buf */ - buf = work; - buf_p =buf_write_alloc (&buf,BLENZ (&src)); +struct buffer buf = work; +void *buf_p =buf_write_alloc (&buf,BLENZ (&src));ASSERT (buf_p);memcpy (buf_p,BPTR (&src),BLENZ (&src));
@@ -345,7 +344,6 @@struct buffer encrypt_workspace =alloc_buf_gc (BUF_SIZE (&frame), &gc);struct buffer decrypt_workspace =alloc_buf_gc (BUF_SIZE (&frame), &gc);struct buffer work =alloc_buf_gc (BUF_SIZE (&frame), &gc); -struct buffer buf =clear_buf ();struct buffer src =alloc_buf_gc (frame.buf.payload_size, &gc);void *buf_p;
@@ -360,7 +358,7 @@prng_bytes (BPTR (&src),BLEN (&src));/* copy source to input buf */ - buf = work; +struct buffer buf = work; buf_p =buf_write_alloc (&buf,BLENZ (&src));ASSERT (buf_p);memcpy (buf_p,BPTR (&src),BLENZ (&src));
@@ -641,7 +639,6 @@struct buffer work =alloc_buf_gc (BUF_SIZE (&frame), &gc);struct buffer encrypt_workspace =alloc_buf_gc (BUF_SIZE (&frame), &gc);struct buffer decrypt_workspace =alloc_buf_gc (BUF_SIZE (&frame), &gc); -struct buffer buf =clear_buf ();void *buf_p;/* init work */
@@ -658,7 +655,7 @@ASSERT (buf_write (&src, plaintext,strlen (plaintext)));/* copy source to input buf */ - buf = work; +struct buffer buf = work; buf_p =buf_write_alloc (&buf,BLENZ (&src));ASSERT (buf_p);memcpy (buf_p,BPTR (&src),BLENZ (&src));
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1617?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Id0caa497c4ff1ad8743cb23f332f003b2d3393ed
Gerrit-Change-Number: 1617
Gerrit-PatchSet: 22
Gerrit-Owner: flichtenheld <[email protected]>
Gerrit-Reviewer: cron2 <[email protected]>
Gerrit-Reviewer: plaisthos <[email protected]>
Gerrit-Reviewer: razvanc <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: stipa <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
flichtenheld has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1617?usp=email )
Change subject: Remove various useless assignments
......................................................................
Patch Set 22:
(1 comment)
File src/openvpn/pkcs11_openssl.c:
http://gerrit.openvpn.net/c/openvpn/+/1617/comment/8dec46c9_ec352a8b?usp=email :
PS21, Line 187: sigalg.op = "Sign";
Quoted 1 line
My cppcheck run also flagged this as an
unreadVariable. […]
No. But that hit only occurs with newer versions of cppcheck than I originally used which is why it was not part of this commit.
I have investigated it and it is correct. It is somewhat indirect though. We give the full sigalg struct to a function that then also doesn't use .op.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1617?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Id0caa497c4ff1ad8743cb23f332f003b2d3393ed
Gerrit-Change-Number: 1617
Gerrit-PatchSet: 22
Gerrit-Owner: flichtenheld <[email protected]>
Gerrit-Reviewer: cron2 <[email protected]>
Gerrit-Reviewer: plaisthos <[email protected]>
Gerrit-Reviewer: razvanc <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: stipa <[email protected]>
Gerrit-Comment-Date: Mon, 14 Sep 2026 12:02:04 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: razvanc <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel